Deploy the openshift-nexus3 helm chart on Azure Kubernetes Service (AKS)
TypeScriptTo deploy the
openshift-nexus3
Helm chart on Azure Kubernetes Service (AKS), we'll follow several steps to create the necessary infrastructure and deploy the application.- Create an AKS Cluster: Using Pulumi's
azure-native
provider, we will provision a new AKS cluster where our application will run. - Deploy Helm Chart: After setting up the AKS cluster, we'll use Pulumi's
kubernetes
provider to deploy the Helm chart to the cluster.
Let's break down the process step-by-step, explaining what each part of the program does.
Step 1: Provision an AKS Cluster
We will define an AKS cluster using the
azure-native
provider. The code will specify the necessary parameters for the cluster, such as the node size, the number of nodes, and the location.Step 2: Deploy Helm Chart
Once the cluster is up and running, we'll configure Pulumi to use the
kubernetes
provider to install Helm charts. To deploy theopenshift-nexus3
chart, we'll need to specify the repository where this chart is located and then instruct Pulumi to install it into our AKS cluster.Now, let's go through the Pulumi program in TypeScript:
import * as pulumi from "@pulumi/pulumi"; import * as azureNative from "@pulumi/azure-native"; import * as k8s from "@pulumi/kubernetes"; // Create a resource group to contain the AKS cluster const resourceGroup = new azureNative.resources.ResourceGroup("resourceGroup", { location: "East US", }); // Create an AKS cluster const cluster = new azureNative.containerservice.ManagedCluster("aksCluster", { resourceGroupName: resourceGroup.name, location: resourceGroup.location, agentPoolProfiles: [{ count: 3, vmSize: "Standard_DS2_v2", mode: "System", }], dnsPrefix: "aks-nexus3", enableRBAC: true, }); // Export the Kubeconfig export const kubeconfig = cluster.kubeConfig; // Set up a K8s provider using the generated kubeconfig from previous step const k8sProvider = new k8s.Provider("k8sProvider", { kubeconfig: cluster.kubeConfig.apply(JSON.stringify), }); // Deploy the openshift-nexus3 Helm chart const chart = new k8s.helm.v3.Chart("nexus-chart", { chart: "nexus-repository-manager", version: "29.0.3", // you should replace with the version number you require. fetchOpts: { repo: "https://sonatype.github.io/helm3-charts/", // replace if the Helm chart is located at a different repository }, }, { provider: k8sProvider }); // Export the endpoint of Nexus Repository Manager export const nexusEndpoint = pulumi.interpolate`http://${chart.getResourceProperty("v1/Service", "nexus-nexus-repo", "status").apply(status => status.loadBalancer.ingress[0].ip)}:8081`;
In this program, we define the resources required to deploy the
openshift-nexus3
Helm chart onto an AKS cluster. Let's break down the major parts of this code:-
Resource Group Creation: We create an Azure resource group to logically organize the resources. The location is specified as "East US", but you should select the region that is closest to your users or has the best latency.
-
AKS Cluster Creation: We create a new AKS cluster within our resource group. The
agentPoolProfiles
property determines the size and number of VMs running the Kubernetes nodes. ThednsPrefix
is used for the DNS name of the AKS cluster. -
Export Kubeconfig: The output of the
kubeConfig
is exported, which contains credentials for accessing the Kubernetes cluster. This is necessary for managing the cluster and deploying applications to it. -
Kubernetes Provider Setup: We instantiate a Pulumi Kubernetes provider that uses the kubeconfig we obtained from the AKS cluster creation. This provider enables us to interact with the Kubernetes cluster.
-
Helm Chart Deployment: We deploy the
openshift-nexus3
Helm chart (specified here asnexus-repository-manager
) onto our AKS cluster using the Helm provider. We specify the chart version we wish to deploy, and the repository where the Helm chart is located. -
Nexus Endpoint Export: Finally, we export the endpoint at which the Nexus Repository Manager will be accessible. This enables you to access the deployed Nexus UI externally.
After running this Pulumi program, you should have a functioning AKS cluster with the
openshift-nexus3
Nexus Repository Manager deployed. You can access Nexus using the exportednexusEndpoint
.Please ensure that you have the Pulumi CLI installed and configured for Azure before running this program. You can deploy this program using standard Pulumi CLI commands:
pulumi up
This will provision the resources in your Azure account. Remember to review the proposed changes before confirming the deployment.
After you have confirmed and the deployment is successful, you can access the Nexus Repository Manager using the endpoint that Pulumi exports at the end of the deployment.
- Create an AKS Cluster: Using Pulumi's