Deploy the springboot-app helm chart on Azure Managed Openshift Service
TypeScriptTo deploy the
springboot-app
Helm chart on Azure Managed OpenShift Service, we will use Pulumi'sazure-native
package for provisioning the Azure Managed OpenShift Service and thekubernetes
package for deploying the Helm chart.The process involves three major steps:
- Creating an Azure Managed OpenShift cluster using the
azure-native.containerservice.OpenShiftManagedCluster
resource. - Setting up a KubeConfig to interact with the OpenShift cluster.
- Deploying the Helm chart using the
kubernetes.helm.v3.Chart
resource.
Here is a program written in TypeScript that accomplishes these steps:
import * as pulumi from "@pulumi/pulumi"; import * as azure_native from "@pulumi/azure-native"; import * as k8s from "@pulumi/kubernetes"; // Step 1: Create the Azure Managed OpenShift cluster const resourceGroupName = new azure_native.resources.ResourceGroup("resourceGroup", { resourceGroupName: "myResourceGroup", location: "East US", // Choose the appropriate Azure location }); const openshiftCluster = new azure_native.containerservice.OpenShiftManagedCluster("openshiftCluster", { resourceName: "myOpenShiftCluster", resourceGroupName: resourceGroupName.name, location: resourceGroupName.location, openShiftVersion: "4.3", // Specify the OpenShift version // Note: The following are placeholder values, you should replace these with real values or acceptance mechanisms for your scenario networkProfile: { vnetCidr: "10.0.0.0/8", }, masterPoolProfile: { count: 1, // Replace with an appropriate VM size vmSize: "Standard_DS3_v2", }, agentPoolProfiles: [ { name: "agentPool", count: 3, osType: "Linux", vmSize: "Standard_DS3_v2", role: "compute", }, ], }); // Step 2: Obtain the KubeConfig // Here we assume the KubeConfig can be obtained externally and securely // The real KubeConfig should be handled carefully since it gives access to your cluster const kubeConfig: pulumi.Output<string> = pulumi.output("<YOUR_KUBE_CONFIG>"); // Step 3: Deploy the Helm chart to the OpenShift cluster const k8sProvider = new k8s.Provider("k8sProvider", { kubeconfig: kubeConfig, }); const helmChart = new k8s.helm.v3.Chart("springboot-app", { chart: "springboot", version: "1.0.0", // replace with your desired chart version // You can specify the repository if your chart is not in the stable repository or add configuration values like below // repo: "https://example.com/helm-charts", values: { // Specify any values that you want to override in the chart }, }, { provider: k8sProvider }); // Export the OpenShift cluster's kubeconfig export const kubeConfigOutput = kubeConfig;
Please, replace the placeholder values with the actual values suited to your needs. Be particularly careful with sensitive information such as OpenShift versions, subscription details, virtual network configurations, and KubeConfig. Usually, for production workloads, KubeConfig should be handled securely and not exposed in plain text. It is also important to size your VM and count for the master and agent pool profiles according to your application requirements and budget.
Remarks:
- The
resourceGroupName
resource declaration creates a new resource group for our OpenShift cluster. - The
openshiftCluster
resource declaration creates an instance of Azure Managed OpenShift Service. Make sure to put the right configurations as needed. - The
kubeConfig
variable should hold your Kubernetes configuration for the newly created cluster, which you would typically get from the Azure portal or CLI after the cluster is provisioned. - The
k8sProvider
resource is a Pulumi provider that allows you to interact with your Kubernetes cluster. - The
helmChart
resource declaration downloads and deploys the Helm chartspringboot
(assumed to be the name of your Spring Boot application Helm chart). Here, thevalues
property can be specified to override default chart values.
⚠️ Security Considerations: Take care not to expose sensitive data like KubeConfig. Pulumi has features like Secrets to help keep sensitive data secure.
To run this Pulumi program:
- Ensure that Pulumi is installed and configured for use with Azure.
- Have the Azure CLI installed and you are logged in (run
az login
). - Replace placeholder values with your specific details where mentioned in the comments.
- Save the above code to a file named
index.ts
. - Run
npm install
to install the necessary Pulumi packages. - Execute
pulumi up
to provision the resources as per the Pulumi program.
- Creating an Azure Managed OpenShift cluster using the