Deploy the axonops helm chart on Oracle Kubernetes Engine (OKE)
TypeScriptTo deploy the AxonOps helm chart on Oracle Kubernetes Engine (OKE), we are going to use Pulumi with the Kubernetes and OCI (Oracle Cloud Infrastructure) providers. This process involves several steps:
- Setting up the OCI provider to manage Oracle Cloud resources.
- Creating or configuring an OKE cluster to run our Kubernetes workloads.
- Setting up the Kubernetes provider to deploy Helm charts on the OKE cluster.
- Deploying the AxonOps Helm chart to the cluster.
Below is the Pulumi program written in TypeScript that accomplishes these steps:
import * as pulumi from "@pulumi/pulumi"; import * as oci from "@pulumi/oci"; import * as k8s from "@pulumi/kubernetes"; // Step 1: Set up the OCI provider const provider = new oci.Provider("oci", { // You need to setup 'tenancyOcid', 'userOcid', 'fingerprint', 'region', 'privateKey' for the OCI provider. // These values should be configured in the Pulumi.oci.yaml file or through environment variables. }); // Load the compartment OCID from configuration const compartmentOcid = pulumi.config.require("compartmentOcid"); // Step 2: Create or configure an OKE cluster const cluster = new oci.containerengine.Cluster("example-cluster", { compartmentId: compartmentOcid, vcnId: /* Use an existing VCN OCID or create a new one */, kubernetesVersion: "v1.20.8", options: { // Additional options if necessary }, }, { provider }); const nodePool = new oci.containerengine.NodePool("example-node-pool", { clusterId: cluster.id, compartmentId: compartmentOcid, nodeShape: "VM.Standard2.1", nodeConfigDetails: { size: 3, // Desired number of nodes placementConfigs: [{ availabilityDomain: "ANY", subnetId: /* Replace with your subnet OCID */ }], }, }, { provider }); // Step 3: Set up the Kubernetes provider using the Kubeconfig from the created OKE cluster const kubeconfig = pulumi. all([cluster.id, cluster.endpoints]). apply(([id, endpoints]) => oci.containerengine.getClusterKubeconfig({ clusterId: id!, endpoint: endpoints.kubernetes, }, { async: true })); const k8sProvider = new k8s.Provider("k8sProvider", { kubeconfig: kubeconfig.value, }, { dependsOn: [nodePool] }); // Step 4: Deploy the AxonOps Helm chart const axonOpsChart = new k8s.helm.v3.Chart("axonops-helm-chart", { chart: "axonops", fetchOpts: { repo: "http://helm.axonops.com/", // The repository where the AxonOps Helm chart is located }, // Specify any custom values here using 'values' property if necessary }, { provider: k8sProvider }); // Export the cluster's kubeconfig and the service endpoint of AxonOps export const kubeconfigOutput = kubeconfig; export const axonOpsEndpoint = axonOpsChart.getResourceProperty("v1/Service", "axonops-helm-chart-axonops", "status").apply(status => status.loadBalancer.ingress[0].ip);
Explanation:
- We begin by importing the required Pulumi packages:
pulumi
for base Pulumi functionalities,oci
for Oracle Cloud Infrastructure, andk8s
for Kubernetes-related operations. - We set up an OCI provider, which requires authentication details like
tenancyOcid
,userOcid
,fingerprint
,region
, andprivateKey
. These should be securely configured either in thePulumi.oci.yaml
configuration file or by setting environment variables. - Next, we create an OKE cluster using
oci.containerengine.Cluster
and a node pool withoci.containerengine.NodePool
. These resources manage the lifecycle of your Kubernetes cluster and the virtual machines running the Kubernetes nodes, respectively. (You will need to replace placeholders with your actual VCN OCID and subnet OCID. This example assumes you have an existing VCN and subnet where you want to launch your OKE cluster. If not, you'll need to create them.) - After creating the cluster, we obtain the kubeconfig that will be used by the Kubernetes provider to interact with the cluster. We use
pulumi.all
in combination with.apply
to asynchronously fetch the kubeconfig after the cluster has been provisioned. - With kubeconfig in hand, we initialize the Kubernetes provider.
- Lastly, we deploy the AxonOps Helm chart using the
k8s.helm.v3.Chart
resource. This step assumes that the AxonOps helm chart is publicly available in the specified Helm repository. - The program exports the cluster's kubeconfig and, once the AxonOps application is deployed, also exports the service endpoint IP address.
Make sure you replace the placeholders with the proper configuration values for your Oracle Cloud Infrastructure and that you review and customize your Helm chart deployment as necessary, particularly in cases where you need to specify custom values.
This program should be saved in a file with a
.ts
extension and run within a Pulumi project. Ensure that you have Pulumi installed and your OKE credentials configured correctly before runningpulumi up
to apply the configuration and deploy the resources.