diff --git a/README.md b/README.md index f3f4fad..881103d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,19 @@ -# Proxmox Cloud Controller Manager +# Kubernetes cloud controller manager for Proxmox + +In my opinion, Proxmox is like a manual way of creating a cloud. +There isn't much automation built into it. +Proxmox is a good option if you have a static infrastructure or don't create new virtual machines very often. +I personally use terraform to launch kubernetes nodes, and when I scale down, I need to delete the node resource in kubernetes. +That's why I created the CCM (Cloud Controller Manager). +Originally, it was designed to work with [TalosCCM](https://github.com/siderolabs/talos-cloud-controller-manager), but it was not difficult to make it a standalone solution. + +The CCM does a few things: it initialises new nodes, applies common labels to them, and removes them when they're deleted. It also supports multiple clusters, meaning you can have one kubernetes cluster across multiple Proxmox clusters. + +The basic definitions: +* kubernetes `region` is a Proxmox cluster +* kubernetes `zone` is a hypervisor host machine name + +This makes it possible for me to use pods affinity/anti-affinity. ## Example @@ -40,16 +55,54 @@ status: type: Hostname ``` -## Install +# Install -### kubectl +## Create a token + +Official [documentation](https://pve.proxmox.com/wiki/User_Management) + +```shell +# Create role CCM +pveum role add CCM -privs "VM.Audit" +# Create user and grant permissions +pveum user add kubernetes@pve +pveum aclmod / -user kubernetes@pve -role CCM +pveum user token add kubernetes@pve ccm -privsep 0 +``` + +## Deploy CCM + +### Method 1: kubectl + +Deploy Proxmox CCM ```shell kubectl apply -f https://raw.githubusercontent.com/sergelogvinov/proxmox-cloud-controller-manager/main/docs/deploy/cloud-controller-manager.yml ``` -### Helm install +Change the proxmox credentials ```shell -helm upgrade -i --namespace=kube-system proxmox-cloud-controller-manager charts/proxmox-cloud-controller-manager +kubectl -n kube-system edit secrets proxmox-cloud-controller-manager +``` + +### Method 2: helm chart + +Set the proxmox credentials + +```yaml +# clusters.yaml +config: + clusters: + - url: https://cluster-api-1.exmple.com:8006/api2/json + insecure: false + token_id: "kubernetes@pve!ccm" + token_secret: "secret" + region: cluster-1 +``` + +Deploy Proxmox CCM + +```shell +helm upgrade -i --namespace=kube-system -f clusters.yaml proxmox-cloud-controller-manager charts/proxmox-cloud-controller-manager ``` diff --git a/charts/proxmox-cloud-controller-manager/templates/deployment.yaml b/charts/proxmox-cloud-controller-manager/templates/deployment.yaml index d48acba..5884ea9 100644 --- a/charts/proxmox-cloud-controller-manager/templates/deployment.yaml +++ b/charts/proxmox-cloud-controller-manager/templates/deployment.yaml @@ -14,13 +14,20 @@ spec: {{- include "proxmox-cloud-controller-manager.selectorLabels" . | nindent 6 }} template: metadata: - {{- with .Values.podAnnotations }} annotations: + {{- if .Values.config }} + checksum/config: {{ toJson .Values.config | sha256sum }} + {{- end }} + {{- with .Values.podAnnotations }} {{- toYaml . | nindent 8 }} {{- end }} labels: {{- include "proxmox-cloud-controller-manager.selectorLabels" . | nindent 8 }} spec: + enableServiceLinks: false + {{- if .Values.priorityClassName }} + priorityClassName: {{ .Values.priorityClassName }} + {{- end }} {{- with .Values.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }}