This talk contains some copy-paste content from Marcel Müller (twitter.com/MueMarcel)’s old talk. Scope For Cluster API users, not for provider maintainers.
a human operator - how the system ought to behave - how to deploy it - how to react if there are problems - k8s operator = one or more controllers for a specific thing - e.g. MySql Operator, Prometheus Operator etc.
Cluster API ➢ e.g. KubeadmControlPlane • Pod-based ➢ In external cluster, pod based, exposed by a k8s service • External or Managed ➢ controlled by another system like GKE, AKS, EKS, etc. We will talk about only this one
provider - Kubeadm as bootstrap provider - KubeadmControlPlane as controlplane provider These are just examples to understand the concepts. Don’t forget
controlPlaneRef: apiVersion: controlplane.cluster.x-k8s.io/v1beta1 kind: KubeadmControlPlane name: demo1 namespace: org-multi-project infrastructureRef: apiVersion: infrastructure.cluster.x-k8s.io/v1alpha5 kind: OpenStackCluster name: demo1 namespace: org-multi-project As as Cluster API user I want to have a cluster With this control plane provider On this infra provider
Operator) - CR to declare common/primary infra resources for the cluster - Project / Account in infra provider - Credentials to access infra provider - VPC / Network configuration - Region / Availability Zone / Failure Domains
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha5 kind: OpenStackMachine name: demo1-default-91da4cd9-m7gn2 namespace: org-multi-project uid: d7ac11dd-d41c-40a4-9a4b-ab2fe5dd71ad bootstrap: configRef: apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 kind: KubeadmConfig name: demo1-region1-8342e0a3-lwlqx namespace: org-multi-project uid: 5a31ddc4-92e3-4bc9-9af3-d7827e6366fc dataSecretName: demo1-region1-8342e0a3-lwlqx As as Cluster API user I want to have a machine On this infra provider With this bootstrap configuration
- content: | ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AA... path: /etc/ssh/trusted-user-ca-keys.pem permissions: "0600" joinConfiguration: discovery: bootstrapToken: apiServerEndpoint: xxx.yyy.ttt.zzz:6443 token: u7zw64.mytoken nodeRegistration: kubeletExtraArgs: eviction-hard: memory.available<200Mi feature-gates: ExpandPersistentVolumes=true name: '{{ local_hostname }}' postKubeadmCommands: - systemctl restart sshd format: cloud-config As as Cluster API user I want to bootstrap my machine By injecting these files By using this join configuration By using this kubelet configuration By running these commands By using this format
write_files: - path: /etc/ssh/trusted-user-ca-keys.pem permissions: '0600' content: | ssh-ed25519 dfdsfs [email protected] - path: /run/kubeadm/kubeadm-join-config.yaml owner: root:root permissions: '0640' content: | --- apiVersion: kubeadm.k8s.io/v1beta3 runcmd: - kubeadm join --config /run/kubeadm/kubeadm-join-config.yaml - "systemctl restart sshd" users: - name: giantswarm sudo: ALL=(ALL) NOPASSWD:ALL The secret content is in one of the supported formats. cloud-config files are special scripts designed to be run by the cloud-init service.
configuration from Machine CR (by following owner references) and uses that as user_data for cloud-init while creating a machine. KubeadmConfig k8s secret user_data kubeadm config real k8s configuration bootstrap operator infra operator cloud-init kubeadm init
need a control plane to join. Where is the control plane? In the beginning, in the Cluster CR, we mentioned KubeadmControlPlane. Let’s talk about it. VPC / Network
by Cluster - Refers control-plane configuration - api-server - controller-manager - scheduler - etcd - Contains fields of KubeadmConfig too since every control plane node is also a node :)
KubeadmControlPlane metadata: name: demo1-rrsnf spec: clusterConfiguration: controlPlanePart: standardNodeConfigurationPart: machineTemplate: infrastructureRef: apiVersion: infrastructure.cluster.x-k8s.io/v1alpha5 kind: OpenStackMachineTemplate name: demo1-control-plane-91da4cd9 ControlPlane operator creates a special KubeadmConfig for controlplane nodes by using control-plane specific and generic configuration in KubeadmControlPlane CR. This KubeadmConfig includes certificates too. kind: KubeadmConfig metadata: name: demo1-rrsnf
earlier, Infra operator creates a machine by using cloud-config provided by Bootstrap operator. At the end, the created node is a control-plane node. kind: OpenStackMachine metadata: name: demo1-control-plane-.... kind: KubeadmConfig metadata: name: demo1-rrsnf kind: Machine metadata: name: demo1-9jngp spec: bootstrap: configRef: kind: KubeadmConfig name: demo1-rrsnf infrastructureRef: kind: OpenStackMachine name: demo1-control-plane-...
KubeadmControlPlane spec: replicas: 3 rolloutStrategy: rollingUpdate: maxSurge: 1 type: RollingUpdate ControlPlane operator provisions new control-plane nodes according to “replicas” field and rollout nodes during upgrades according to KubeadmControlPlane spec.
clusterName: demo1 maxUnhealthy: 40% nodeStartupTimeout: 20m0s selector: matchLabels: cluster.x-k8s.io/cluster-name: demo1 unhealthyConditions: - status: Unknown timeout: 10m0s type: Ready - status: "False" timeout: 10m0s type: Ready - Part of core api. - Core operator watches machine. If there is a machine which is not in Ready state, it deletes that machine and create a new one.
clusterSelector: matchLabels: cluster.x-k8s.io/cluster-name: demo1 resources: - kind: ConfigMap name: demo1-coredns strategy: ApplyOnce As as Cluster API user In every cluster with these labels I want to create this k8s object automatically.
name: MachinePool - Like MachineDeployment but doesn’t use MachineSet - Delegates the responsibility of these concerns to an infrastructure provider specific resource such as AWS Auto Scale Groups, GCP Managed Instance Groups, and Azure Virtual Machine Scale Sets.
apps in the app catalogs - giantswarm/giantswarm-catalog - giantswarm/default-catalog - We use the app platform to create WCs too. - giantswarm/cluster-api-app - giantswarm/cluster-catalog - Upgrade = changing app version
any WC by just changing a URL param - Grafana: There are many built-in dashboard - Loki, EFK stack - Note: GiantSwarm monitors all clusters and gives 7/24 support. - Security - Kyverno: There are some built-in policies for secure clusters - Falco - Trivy - Connectivity - linkerd - Kong, ingress
clusters - Get kubeconfig for MC/WC - Get access to MC/WC - Daily ops activities (deploy, rollout, drain etc.) - Open MC apps like prometheus, grafana etc. - We have powerful user tools like kubectl-gs - Easy templating - WC management, especially GS types (e.g. apps) - Web UI (giantswarm/happa)
but not enough for a smooth user experience. We - implement additional/helper operators - for easy upgrades with declarative approach like GitOps - for backup - for cleanup - create useful helm charts (See `cluster-$provider` repos in giantswarm org)