Deploy the xossh helm chart on Oracle Kubernetes Engine (OKE)
TypeScriptTo deploy the
xossh
Helm chart on Oracle Kubernetes Engine (OKE), we'll first ensure that we have an OKE cluster available. In this Pulumi program, we'll define a Kubernetes cluster in Oracle Cloud Infrastructure using OKE. Then, we will deploy thexossh
Helm chart on this cluster.The program will use the
oci
Pulumi provider to interact with Oracle Cloud Infrastructure and create the required cloud resources. Thekubernetes
provider will help us with deploying Helm charts.Here's a step-by-step guide along with the complete Pulumi TypeScript program to achieve this:
- Set up a new OCI Kubernetes cluster using the
oci.ContainerEngine.Cluster
resource. - Create a Kubernetes provider instance that uses the kubeconfig of the created OKE cluster.
- Deploy the
xossh
Helm chart to the OKE cluster.
Make sure you have the Pulumi CLI installed and configured with the appropriate OCI credentials. The OCI provider expects that you have the required IAM permissions to create and manage OKE clusters.
Below is the TypeScript program:
import * as pulumi from "@pulumi/pulumi"; import * as oci from "@pulumi/oci"; import * as k8s from "@pulumi/kubernetes"; // Create an Oracle Cloud Infrastructure OKE cluster const cluster = new oci.containerengine.Cluster("myOkeCluster", { // Specify required properties for the OKE cluster // such as compartmentId, vcnId, and options. // This example uses placeholder values. You will need to replace // these with actual values from your OCI account. compartmentId: "ocid1.compartment.oc1..example", vcnId: "ocid1.vcn.oc1..example", kubernetesVersion: "v1.21.4", name: "oke-cluster", options: { serviceLbSubnetIds: ["ocid1.subnet.oc1..example1", "ocid1.subnet.oc1..example2"], }, }); // Obtain the kubeconfig file from OKE cluster const kubeconfig = pulumi. all([cluster.id, cluster.name]). apply(([id, name]) => { return oci.containerengine.getClusterKubeconfig({ clusterId: id, name: name, }); }); // Create a Kubernetes provider instance using kubeconfig from OKE const k8sProvider = new k8s.Provider("myK8Provider", { kubeconfig: kubeconfig.content, }); // Deploy the xossh Helm chart on the OKE cluster const xosshChart = new k8s.helm.v3.Chart("xossh", { chart: "xossh", version: "1.2.3", // Specify the version of the chart, if necessary fetchOpts: { repo: "https://example.com/helm-charts", // Replace with the Helm chart repository }, }, { provider: k8sProvider }); // Export the public IP of the load balancer to access the deployed chart export const servicePublicIP = xosshChart.getResourceProperty("v1/Service", "xossh", "status").apply(status => status.loadBalancer.ingress[0].ip);
Explanation:
- We import the required modules from
@pulumi/pulumi
,@pulumi/oci
, and@pulumi/kubernetes
. - We create an OKE cluster using the
oci.ContainerEngine.Cluster
class. You need to provide your compartment ID, VCN ID, and other relevant configuration details specific to your Oracle Cloud Infrastructure setup. - We retrieve the kubeconfig file from the OKE cluster. This configuration is required to create the Kubernetes provider.
- With the kubeconfig, we create an instance of
k8s.Provider
, which is used to interact with our OKE cluster. - Using the Kubernetes provider, we deploy the
xossh
Helm chart. Therepo
in thefetchOpts
should be the URL of the Helm charts repository wherexossh
is stored. - This code assumes you've already created the VCN and subnets. You'll need to replace placeholder values with actual IDs from your OCI account.
- Lastly, we export the servicePublicIP, which would be the IP address through which you can access the
xossh
application once it is deployed.
Make sure you replace placeholders in the code above (such as
[...]
) with actual values from your OCI environment. Additionally, theversion
andrepo
properties in the Helm chart specification should match the specific xossh Helm chart you wish to deploy.To apply this program, you need to navigate to the directory with this code and run
pulumi up
, which will provision the resources defined in this program.- Set up a new OCI Kubernetes cluster using the