# Crossplane - GitOps-based Infrastructure as Code through Kubernetes API From [YouTube](https://www.youtube.com/watch?v=n8KjVmuHm7A) ## [0:29](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=29) Infrastructure as code tools used to be called "config management tools" ## [0:43](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=43) Chef and Puppet were kicked out of the game by Ansible ## [0:49](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=49) Terraform and Pulumi came after Ansible. ## [1:16](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=76) Crossplane is more modern, and fulfills modern needs that none of the previous tools fulfill. ## [1:32](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=92) Need 1: Common API that he can use for anything ## [1:42](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=102) Implementing GitOps requires drift detection - how far from the expected state has the application drifted? ## [2:22](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=142) Terraform is technically GitOps-based, but there's still a lot of manual steps ## [2:41](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=161) Terraform won't detect drift if someone manually changes the application. ## [3:37](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=217) The best API to use for everything is Kubernetes. ## [6:14](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=374) The only prerequisite for Crossplane: Kubernetes ## [6:26](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=386) Install Crossplane via Helm/Kustomize, install Crossplane CLI ## [12:32](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=752) Terraform uses HCL as a language for defining config; Crossplane uses YAML (pure Kubernetes) ## [19:38](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=1178) Crossplane detected the manual change and automatically corrects it by putting the application back to the state as defined in the YAML manifest. ## [20:49](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=1249) Using ArgoCD with Crossplane ## [21:16](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=1276) Using ArgoCD means he doesn't have to access the cluster or Crossplane-- he just has to push the updated manifest to Git ## [21:39](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=1299) GitOps-based means everything goes through Git. When you want to make a change to the infrastructure, you don't go through kubectl and you definitely don't make changes in the console UI. You push changes to Git, and your application should also just change accordingly. ## [23:15](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=1395) ArgoCD synchronized what was in Git with what was the actual state of the cluster/application. ## [23:24](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=1404) Crossplane then figured out what needed to be done and communicated it to the application. ## [26:24](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=1584) Limitations of Crossplane: functionality is limited, compared to what you can do with Terraform. ## [27:02](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=1622) If you want to use Crossplane... write your own providers. ## [27:15](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=1635) Crossplane is not the right choice if you want everything to work out of the box. If you are willing to write your own providers and contribute back to the open-source community, then it may be for you. ## [27:52](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=1672) Initial setup with Crossplane is more complex because you need a Kubernetes cluster. ## [28:22](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=1702) But, actually, Terraform has a requirement too: you need to set up storage that Terraform can use to store the states. So the choice is: set up storage for Terraform or set up a cluster for Crossplane. ## [29:07](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=1747) Benefits: Crossplane uses the Kubernetes API. ## [29:48](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=1788) It's not just about uniting everything under one API; it's also about being able to leverage Kubernetes's capabilities, like synchronizing states and drift detection (and correction). ## [30:36](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=1836) Benefit 2: Ability to inject Crossplane into wider Kubernetes ecosystem. ## [30:57](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=1857) Instead of ArgoCD to monitor infrastructure configuration, you could use Flux, or Prometheus to monitor stuff. ## [31:25](https://www.youtube.com/watch?v=n8KjVmuHm7A&t=1885) Crossplane is the first infrastructure management tool that is designed to run in Kubernetes. ``` Farcic, V. (2022) ```