Skip to content

jamesbramich/iac-demo

Folders and files

NameName
Last commit message
Last commit date
May 22, 2024
May 6, 2024
May 8, 2024
Mar 25, 2024
May 22, 2024
May 9, 2024
May 22, 2024
May 22, 2024

Repository files navigation

Crossplane infrastructure as code

Overview

Compared to the likes of Terraform and Pulumi, Crossplane is a relative newcomer to the IaC space. However, as a kubernetes based platform it is appealing by virtue of:

  • leveraging our existing k8s skillset
  • making use of a large and growing k8s ecosystem

The initial strategy is to create a configuration to deploy the base cluster for EKS then follow that with required services e.g. cert-manager, cluster-autoscaler, external-secrets-operator etc. This means a move to a different CSP will only require the cluster deployment to change.

Initial Setup

The intial setup instructions describe how to use an IaC solution that runs in Kubernetes to deploy itself. Thankfully this does not have to be done very often.

Cluster Deployment

The cluster deployments use kustomize to install the kubernetes cluster and components. To improve modularity in terms of deploying clusters that require different components, or in the case of deploying to a different CSP, the deployment is designed as follows:

  • Nofrixion specific composite resource definitions (XRDs) and compositions have beend defined to deploy a VPC and kubernetes cluster to AWS. The configuration is essentially the same as those clusters initially deployed using eksctl
  • Cluster components (e.g. nginx ingress controller, cert-manager, rabbitmq etc.) are deployed as seperate resources.

To deploy a cluster, create a kustomization.yaml (example) file to deploy the following resouces to a specific namespace:

  • a cluster claim, which calls the xrds and compositions to create a specific cluster instance. For example, the it-ops-1 cluster
  • crossplane objects and releases to deploy additional components. Objects use the crossplane kubernetes provider to run the equivalent of kubectl apply ... and Releases use the helm provider to deploy helm charts.

Known Issues

Cluster Autoscaler

Crossplane did not get on with the cluster autoscaler, nodes were scaling up and down constantly. Given Azure AKS and Google GKE have proprietry (and at least in the case of Azure, simple) solutions to node autoprovisioning it is probably work looking at Karpenter to handle this.

However, to manually add a node to the crossplane cluster just change spec.parameters.node.count in the cluster manifest (see example) to the desired value.

Troubleshooting

Deleting 'stuck' resources

This mostly happens during testing but, in case of emergency remove finalisers from the managed resource e.g.

TARGET="{YOUR STUCK RESOURCES NAME}"
kubectl patch $TARGET -p '{"metadata":{"finalizers": []}}' --type=merge

REFERENCES

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published