canonical / cluster-api-bootstrap-provider-microk8s

This project offers a cluster API bootstrap provider controller that manages the node provision of a MicroK8s cluster.
https://microk8s.io
21 stars 14 forks source link

snap store proxy configuration not getting applied on CAPI worker nodes #102

Closed vishvikkrishnan closed 1 week ago

vishvikkrishnan commented 4 months ago

The cluster spec is as follows:

apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
  name: microk8s-maas
  namespace: default
spec:
  controlPlaneRef:
    apiVersion: controlplane.cluster.x-k8s.io/v1beta1
    kind: MicroK8sControlPlane
    name: microk8s-maas-control-plane
  infrastructureRef:
    apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
    kind: MaasCluster
    name: microk8s-maas
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: MaasCluster
metadata:
  name: microk8s-maas
  namespace: default
spec:
  dnsDomain: maas
---
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: MicroK8sControlPlane
metadata:
  name: microk8s-maas-control-plane
  namespace: default
spec:
  controlPlaneConfig:
    clusterConfiguration:
      portCompatibilityRemap: true
    initConfiguration:
      IPinIP: true
      snapstoreProxyDomain: "airgapped-snaps.capi.demo"
      snapstoreProxyId: "Rn0rGwTAE8uRE28ZOgSXiluKZXgMVKzi"
      addons:
      - dns
      joinTokenTTLInSecs: 9000
      preRunCommands:
      - |
        touch preRunCommands.done
      postRunCommands:
      - |
        touch postRunCommands.done
  machineTemplate:
    infrastructureTemplate:
      apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
      kind: MaasMachineTemplate
      name: microk8s-maas-control-plane
  replicas: 3
  version: v1.27.11
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: MaasMachineTemplate
metadata:
  name: microk8s-maas-control-plane
  namespace: default
spec:
  template:
    spec:
      image: ubuntu/jammy
      minCPU: 1
      minMemory: 2048
      resourcePool: null
      tags:
      - controller
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
  name: microk8s-maas-md-0
  namespace: default
spec:
  clusterName: microk8s-maas
  replicas: 3
  selector:
    matchLabels: null
  template:
    spec:
      bootstrap:
        configRef:
          apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
          kind: MicroK8sConfigTemplate
          name: microk8s-maas-md-0
      clusterName: microk8s-maas
      infrastructureRef:
        apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
        kind: MaasMachineTemplate
        name: microk8s-maas-md-0
      version: 1.27.11
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: MaasMachineTemplate
metadata:
  name: microk8s-maas-md-0
  namespace: default
spec:
  template:
    spec:
      image: ubuntu/jammy
      minCPU: 1
      minMemory: 2048
      resourcePool: null
      tags:
      - worker
---
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: MicroK8sConfigTemplate
metadata:
  name: microk8s-maas-md-0
  namespace: default
spec:
  template:
    spec:
      initConfiguration:
        snapstoreProxyDomain: "airgapped-snaps.capi.demo"
        snapstoreProxyId: "Rn0rGwTAE8uRE28ZOgSXiluKZXgMVKzi"

However, in the worker nodes, the cloud-init-output.log indicates that the worker did not have the snap store proxy configured:

+ /capi-scripts/00-configure-snapstore-http-proxy.sh  
+ [[ '' != '' ]]
+ [[ '' != '' ]]
+ /capi-scripts/00-configure-snapstore-proxy.sh  
+ '[' 2 -ne 2 ']'
+ '[' -z '' ']'
+ echo 'Using the default snapstore'
Using the default snapstore
+ exit 0

This feature works as expected on the control plane nodes.

It should be possible to configure the snap store proxy on the worker nodes as well.

eaudetcobello commented 1 month ago

Hi @vishvikkrishnan,

Could you please try again with version 0.6.9 of the providers? clusterctl init -i maas -b microk8s:v0.6.9 -c microk8s:v0.6.9.

The reason I ask is because I was not able to reproduce your issue with this version, everything worked fine.