Using kubernetes argoproj.io with gateway.networking.k8s.io
TypeScriptTo use
argoproj.io
components withgateway.networking.k8s.io
on Kubernetes using Pulumi, you can create a program that sets up the necessary resources. Argo Project is an open-source collection for getting work done with Kubernetes, which includes productivity tools like Argo Workflows, Argo CD, Argo Rollouts, and more.gateway.networking.k8s.io
is part of the Kubernetes Gateway API, which is a collection of resources that model gateway configurations.Description:
- ArgoCD: a declarative, GitOps continuous delivery tool for Kubernetes.
- Ingress: a
gateway.networking.k8s.io/v1alpha2
API resource that provides HTTP and HTTPS routing to services within your Kubernetes cluster.
For this example, we'll assume you would like to deploy an ArgoCD instance and expose it through an Ingress resource from the Gateway API resources. Here's how you would set it up using Pulumi and TypeScript:
import * as k8s from '@pulumi/kubernetes'; // Create a new Kubernetes Namespace for the ArgoCD components. const namespace = new k8s.core.v1.Namespace('argocd', { metadata: { name: 'argocd', }, }); // Deploy ArgoCD using a Helm chart. // You will need to have the argo helm repository added to your helm client. // You can typically do this with `helm repo add argo https://argoproj.github.io/argo-helm` const argocd = new k8s.helm.v3.Chart('argocd', { chart: 'argo-cd', version: '3.2.3', // specify the version you wish to deploy namespace: namespace.metadata.name, fetchOpts: { repo: 'https://argoproj.github.io/argo-helm', }, values: { // Custom values for the ArgoCD chart. // This is where you would specify custom values for your ArgoCD installation. // For a default installation, you can omit the 'values' field, // but you might want to add things here such as custom resource limits, // node selectors, or ingress configuration. }, }, { dependsOn: [namespace] }); // Define an Ingress resource to expose the ArgoCD server service using the Gateway API. const argocdIngress = new k8s.networking.v1alpha2.Ingress('argocd-ingress', { metadata: { name: 'argocd-server-ingress', namespace: namespace.metadata.name, }, spec: { rules: [ { host: 'argocd.example.com', // Specify the domain where you want to access ArgoCD http: { paths: [ { path: '/', pathType: 'Prefix', backend: { service: { name: 'argocd-server', port: { number: 80, // Assuming the ArgoCD service exposes HTTP on port 80 }, }, }, }, ], }, }, ], // If you need to specify TLS settings, you can add a 'tls' block here. }, }, { dependsOn: [argocd] }); // Exports the public URL for the load balancer. export const argoIngressHostname = argocdIngress.status.loadBalancer.ingress[0].hostname;
In this program:
- We first create a new Kubernetes namespace named
argocd
to separate our Argo CD components. - We then deploy Argo CD into this namespace using a Helm chart. The version of the chart is specified along with the custom values needed for the installation.
- After deploying Argo CD, we create an Ingress resource that defines how external traffic should be routed to the Argo CD server service. The
host
field specifies the domain name you want to use to access Argo CD, and we've assumed that the Argo CD server is exposed via port 80 (standard for HTTP).
This Pulumi program assumes that you have already configured the Kubernetes context and the Pulumi CLI to point to the correct cluster and account where you want to deploy these resources.
Once written to a
.ts
file, you can runpulumi up
to apply this configuration to your Kubernetes cluster using Pulumi.Remember to replace
argocd.example.com
with the domain name you want to use, and configure the necessary DNS records to point to the Ingress controller's external IP or domain name.Please note that the Ingress API version
v1alpha2
undernetworking.k8s.io
is an alpha-version feature at the time of writing and might not be available on your Kubernetes cluster or might require enabling Gateway API feature gates. Check the Ingress documentation for the exact API versions supported by your cluster and adjust the import and resource definitions accordingly.