Estou usando o cilium 1.14.3 como o componente kuberenetes v1.28.3 cni, é assim que instalo o cilium:
helm install cilium cilium/cilium --version 1.14.3 \
--namespace kube-system \
--set global.nodeinit.enabled=true \
--set global.kubeProxyReplacement=partial \
--set global.hostServices.enabled=false \
--set global.externalIPs.enabled=true \
--set global.nodePort.enabled=true \
--set global.hostPort.enabled=true \
--set global.pullPolicy=IfNotPresent \
--set config.ipam=kubernetes \
--set global.hubble.enabled=true \
--set global.hubble.relay.enabled=true \
--set global.hubble.ui.enabled=true \
--set global.hubble.metrics.enabled="{dns,drop,tcp,flow,port-distribution,icmp,http}"
agora quero alterar o endereço do servidor API do Kubernetes, editei o configmap cilium-config e adicionei isto:
k8s-service-host: '172.29.217.209'
k8s-service-port: '6443'
k8s-api-server: 'https://172.29.217.209:6443'
esta configuração funciona para o operador cilium, mas descobri que o cilium DeamonSet ainda não usava o novo endereço do servidor API. Então adicionei a configuração no cilium DeamonSet assim:
initContainers:
- name: config
image: >-
quay.io/cilium/cilium:v1.14.3@sha256:e5ca22526e01469f8d10c14e2339a82a13ad70d9a359b879024715540eef4ace
command:
- cilium
- build-config
env:
- name: K8S_API_SERVER
value: 'https://172.29.217.209:6443'
- name: K8S_NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
- name: CILIUM_K8S_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
resources: {}
volumeMounts:
- name: tmp
mountPath: /tmp
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: FallbackToLogsOnError
imagePullPolicy: IfNotPresent
parece que o contêiner inicial não leu o endereço do servidor API. Estou esquecendo de algo? o que devo fazer para alterar o endereço do servidor kube api para o contêiner inicial cilium DeamonSet? Encontrei a configuração em https://docs.cilium.io/en/v1.12/gettingstarted/kubeproxy-free/#kubeproxy-free e acho que funcionará para 1.14.3.
este é o log de erros do contêiner inicial e mostra por que preciso alterar o endereço do servidor API:
level=info msg=Invoked duration="810.146µs" function="cmd.glob..func36 (build-config.go:32)" subsys=hive
level=info msg=Starting subsys=hive
level=info msg="Establishing connection to apiserver" host="https://10.96.0.1:443" subsys=k8s-client
level=info msg="Establishing connection to apiserver" host="https://10.96.0.1:443" subsys=k8s-client
level=error msg="Unable to contact k8s api-server" error="Get \"https://10.96.0.1:443/api/v1/namespaces/kube-system\": dial tcp 10.96.0.1:443: i/o timeout" ipAddr="https://10.96.0.1:443" subsys=k8s-client
level=error msg="Start hook failed" error="Get \"https://10.96.0.1:443/api/v1/namespaces/kube-system\": dial tcp 10.96.0.1:443: i/o timeout" function="client.(*compositeClientset).onStart" subsys=hive
level=info msg=Stopping subsys=hive
Error: failed to start: Get "https://10.96.0.1:443/api/v1/namespaces/kube-system": dial tcp 10.96.0.1:443: i/o timeout
Usage:
cilium build-config --node-name $K8S_NODE_NAME [flags]
Flags:
--allow-config-keys strings List of configuration keys that are allowed to be overridden (e.g. set from not the first source. Takes precedence over deny-config-keys
--deny-config-keys strings List of configuration keys that are not allowed to be overridden (e.g. set from not the first source. If allow-config-keys is set, this field is ignored
--dest string Destination directory to write the fully-resolved configuration. (default "/tmp/cilium/config-map")
--enable-k8s Enable the k8s clientset (default true)
--enable-k8s-api-discovery Enable discovery of Kubernetes API groups and resources with the discovery API
-h, --help help for build-config
--k8s-api-server string Kubernetes API server URL
--k8s-client-burst int Burst value allowed for the K8s client
--k8s-client-qps float32 Queries per second limit for the K8s client
--k8s-heartbeat-timeout duration Configures the timeout for api-server heartbeat, set to 0 to disable (default 30s)
--k8s-kubeconfig-path string Absolute path of the kubernetes kubeconfig file
Golfinho. Como você está usando o Helm, é aconselhável executar o comando conforme a documentação (observe que estou me referindo à versão 1.14.4). Execute o seguinte comando de atualização do Helm para Cilium:
Você pode encontrar todas as chaves relevantes na documentação aqui e não há mais uma chave k8s-api-server.
Depois de executar isso, você pode usar o seguinte comando para inspecionar o Cilium DaemonSet:
Ao fazer isso, você deve observar o seguinte na saída:
Observe que você deve substituir YOUR_API_IP pelo endereço IP real em sua configuração específica.