Prepare a Kubernetes Cluster for an Advanced Appliance¶
Prepare your Kubernetes cluster before connecting an advanced appliance to it: without the permissions, the secret and the name resolution described here, containers do not start. This page applies to an appliance in advanced mode with a Kubernetes orchestration environment that you provide (a k3s cluster, a managed cluster such as AKS, etc.).
Reemo connects to your cluster with a client certificate. This certificate is not an administrator: Reemo only has the permissions you give it. Give it exactly those on this page, no more and no less.
Prerequisites¶
A Kubernetes cluster and an account that can create namespaces, roles and secrets
kubectlandopensslon your administration machineThe
registry.reemo.ioregistry credentials provided by ReemoThe name of your portal’s signal server (
<SIGNAL_HOST>, in the form<PORTAL_URL>-signalas in step 3 of Deploy an Advanced Appliance)
Create the Containers Namespace¶
Reemo creates containers and their disks in a single namespace. All of Reemo’s permissions, except reading the nodes, are limited to this namespace. The example uses reemo; if you choose another name, replace it everywhere on this page.
Create the namespace:
kubectl create namespace reemo
Enter the same name in the Namespace field of the container provider.
Create Reemo’s Identity¶
The client certificate is Reemo’s identity in the cluster: its CN becomes the Kubernetes user name and its O the group. The permissions in the next section are given to this user.
Important
Never use O=system:masters: this group has all permissions on the cluster, and no role can limit them.
Generate the private key:
openssl genrsa -out reemo.key 2048
Generate the certificate request, with
CN=reemoandO=reemo:openssl req -new -key reemo.key -subj "/O=reemo/CN=reemo" -out reemo.csr
Have the request signed by the cluster’s client certificate authority:
On a k3s server, sign with the k3s client CA:
sudo openssl x509 -req -in reemo.csr \ -CA /var/lib/rancher/k3s/server/tls/client-ca.crt \ -CAkey /var/lib/rancher/k3s/server/tls/client-ca.key \ -CAcreateserial -out reemo.crt -days 365
On any other cluster, use the kube API. Encode the request:
base64 -w0 reemo.csr
Create a
reemo-csr.yamlfile with the value you obtained:apiVersion: certificates.k8s.io/v1 kind: CertificateSigningRequest metadata: name: reemo spec: request: <BASE64_REQUEST> signerName: kubernetes.io/kube-apiserver-client usages: - client auth
Apply it, approve it, then retrieve the certificate:
kubectl apply -f reemo-csr.yaml kubectl certificate approve reemo kubectl get csr reemo -o jsonpath='{.status.certificate}' | base64 -d > reemo.crt
Check the certificate subject:
openssl x509 -in reemo.crt -noout -subject
Expected result:
subject=O = reemo, CN = reemo.
Use reemo.crt, reemo.key and the server’s authority certificate in the provider configuration (see Deploy an Advanced Appliance).
Note
On an AKS cluster with Microsoft Entra ID and Azure RBAC, a client certificate is not an Entra identity: Azure does not decide (message Azure does not have opinion for this non AAD user) and only Kubernetes RBAC applies. Local accounts must remain enabled. An Azure role assignment gives Reemo no permissions.
Give Reemo Its Permissions¶
Reemo needs to read and write in the containers namespace, and to read the list of nodes. A single file contains two roles: a Role limited to the namespace and a read-only ClusterRole.
Resource |
Verbs |
Scope |
Used for |
|---|---|---|---|
|
|
namespace |
creating, tracking and deleting containers |
|
|
namespace |
container status, Containers and Secrets pages of the provider’s detail page |
|
|
namespace |
looking up the container’s disk before every container creation, whatever the image; Containers and Volumes pages of the provider’s detail page |
|
|
namespace |
images with a persistent disk (since 2.6.0): creating the disk, deleting it with the container |
|
|
namespace |
checking the namespace |
|
|
cluster |
Nodes and Containers pages of the provider’s detail page, node diagnostics; not required to start containers |
Important
Without list on the namespace’s persistentvolumeclaims, no container starts, including images without a disk such as bastions: Reemo looks for the container’s disk before creating it. Without delete, the disk of a deleted container stays in the cluster, with no error message.
Create the
reemo-rbac.yamlfile:apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: reemo-containers namespace: reemo rules: - apiGroups: ["apps"] resources: ["deployments"] verbs: ["get", "list", "create", "delete"] - apiGroups: [""] resources: ["pods", "secrets"] verbs: ["list"] - apiGroups: [""] resources: ["persistentvolumeclaims"] verbs: ["list", "create", "delete"] - apiGroups: [""] resources: ["namespaces"] verbs: ["get"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: reemo-containers namespace: reemo roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: reemo-containers subjects: - apiGroup: rbac.authorization.k8s.io kind: User name: reemo --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: reemo-nodes rules: - apiGroups: [""] resources: ["nodes"] verbs: ["list"] - apiGroups: ["metrics.k8s.io"] resources: ["nodes"] verbs: ["list"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: reemo-nodes roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: reemo-nodes subjects: - apiGroup: rbac.authorization.k8s.io kind: User name: reemo
Apply the file:
kubectl apply -f reemo-rbac.yaml
Expected result: four
createdlines (orconfigured).
Note
Do not combine these permissions into a single ClusterRole: Reemo could then create and delete deployments and read the secrets of every namespace in the cluster.
Create the Registry Secret¶
Pods download their images from registry.reemo.io using a secret whose name is fixed: registry-reemo-io-creds, of type kubernetes.io/dockerconfigjson, in the containers namespace. Without it, pods stay in ImagePullBackOff.
Create the secret with the credentials provided by Reemo:
kubectl create secret docker-registry registry-reemo-io-creds -n reemo \ --docker-server=registry.reemo.io \ --docker-username=<USERNAME> \ --docker-password='<PASSWORD>'
Check that it exists:
kubectl get secret registry-reemo-io-creds -n reemo
Expected result: one line of type
kubernetes.io/dockerconfigjson.
Check and Fix DNS Resolution from a Pod¶
Pods reach the signal server, not the host. A name declared only in the nodes’ /etc/hosts file is not seen by pods.
Start a test pod that resolves the signal server name:
kubectl run test-dns -n reemo --rm -it --restart=Never --image=busybox -- nslookup <SIGNAL_HOST>
Expected result: an IP address.
If the name does not resolve, declare the zone in CoreDNS. On k3s and AKS, the coredns-custom ConfigMap in the kube-system namespace holds custom zones.
Save this manifest as
coredns-custom.yaml, replacingexample.com,192.0.2.10and the two names (<PORTAL_URL>and<PORTAL_URL>-signal) with the values for your portal:apiVersion: v1 kind: ConfigMap metadata: name: coredns-custom namespace: kube-system data: example.server: | example.com:53 { hosts { 192.0.2.10 <PORTAL_URL> <PORTAL_URL>-signal } }
Apply the manifest, then restart CoreDNS:
kubectl apply -f coredns-custom.yaml kubectl rollout restart deployment coredns -n kube-system
Run the test command from step 1 again.
Expected result: an IP address.
Choose the Storage Class¶
This step only applies to images with a persistent disk (see Create an ALU Image with a Persistent Disk).
List the cluster’s storage classes:
kubectl get storageclass
Enter the name of the class you chose in the Storage Class Name field of the volume, in the image’s Template tab.
Note
A local class (such as k3s’s local-path) ties the disk, and therefore the container, to a single node. A managed disk class is usually limited to one zone. Choose it knowingly.
Check the Permissions¶
The provider’s Test button only checks the connection: it succeeds even if Reemo has no permissions. Check the permissions with Reemo’s own certificate.
Create a kubeconfig file that uses Reemo’s certificate (
ca.crtis the server authority’s certificate):kubectl config set-cluster target --server=https://<KUBE_API>:6443 --certificate-authority=ca.crt --embed-certs --kubeconfig=reemo.kubeconfig kubectl config set-credentials reemo --client-certificate=reemo.crt --client-key=reemo.key --embed-certs --kubeconfig=reemo.kubeconfig kubectl config set-context reemo --cluster=target --user=reemo --namespace=reemo --kubeconfig=reemo.kubeconfig kubectl config use-context reemo --kubeconfig=reemo.kubeconfig
List Reemo’s permissions in the namespace:
kubectl auth can-i --list -n reemo --kubeconfig=reemo.kubeconfig
Expected result: the lines
deployments.apps,persistentvolumeclaims,pods,secrets,namespacesandnodeswith the verbs from the table above.Delete
reemo.kubeconfig: it contains Reemo’s private key.
If a container does not start despite these checks, look at the appliance log on the Connector (see Appliance Operations and Maintenance).
After an Update¶
A new version of Reemo may require one more permission. After every INFRA or appliance update, start a test container and check that the appliance log contains no 403 code.
See also
Deploy an Advanced Appliance — Deploy the appliance in advanced mode.