Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong etcd listen-metrics-urls customization for second and further controlPlane nodes #4024

Closed
maximsnezhkov opened this issue Dec 16, 2020 · 9 comments
Labels
area/control-plane Issues or PRs related to control-plane lifecycle management kind/bug Categorizes issue or PR as related to a bug.
Milestone

Comments

@maximsnezhkov
Copy link

maximsnezhkov commented Dec 16, 2020

What steps did you take and what happened:
I use local managment cluster based on minukube. Trying to customize listen-metrics-urls for etcd with following kcp config

---
apiVersion: controlplane.cluster.x-k8s.io/v1alpha3
kind: KubeadmControlPlane
metadata:
  name: maxim-test
  namespace: default
spec:
  infrastructureTemplate:
    apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3
    kind: VSphereMachineTemplate
    name: maxim-test
  kubeadmConfigSpec:
    clusterConfiguration:
      etcd:
        local:
          imageTag: "3.4.13-0"
          extraArgs:
            listen-metrics-urls: "http://{{ ds.meta_data.local_ipv4 }}:2381"

The problem is that ds.meta_data.local_ipv4 is expanded the same for second and further nodes. And has the ip address of the first node.

first node:

$ ssh 10.10.10.2
$ sudo grep listen-metrics-urls /etc/kubernetes/manifests/etcd.yaml
    - --listen-metrics-urls=http://10.10.10.2:2381
$
Connection to 10.10.10.2 closed.

second node:

$ ssh 10.10.10.3
$ sudo grep listen-metrics-urls /etc/kubernetes/manifests/etcd.yaml
    - --listen-metrics-urls=http://10.10.10.2:2381
$
Connection to 10.10.10.3 closed.

What did you expect to happen:
I expect that ds.meta_data.local_ipv4 will be expanded in a different ip address on second and further nodes.

Anything else you would like to add:
As a workaround now I set

---
apiVersion: controlplane.cluster.x-k8s.io/v1alpha3
kind: KubeadmControlPlane
metadata:
  name: maxim-test
  namespace: default
spec:
  infrastructureTemplate:
    apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3
    kind: VSphereMachineTemplate
    name: maxim-test
  kubeadmConfigSpec:
    clusterConfiguration:
      etcd:
        local:
          imageTag: "3.4.13-0"
          extraArgs:
            listen-metrics-urls: 'http://0.0.0.0:2381'

Environment:
Management cluster:

  • Cluster-api version: 0.3.12
  • Minikube/KIND version: v1.15.1
  • Kubernetes version: (use kubectl version): v1.19.4
  • OS (e.g. from /etc/os-release): official CAPV OVA image - ubuntu-1804-kube-v1.19.1

/kind bug

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Dec 16, 2020
@maximsnezhkov
Copy link
Author

maximsnezhkov commented Dec 16, 2020

The same way wrong customization for liveness/startup probes on the second node.
10.10.10.2 instead of 10.10.10.3:

    livenessProbe:
      failureThreshold: 8
      httpGet:
        host: 10.10.10.2
        path: /health
        port: 2381
        scheme: HTTP
      initialDelaySeconds: 10
      periodSeconds: 10
      timeoutSeconds: 15
...
    startupProbe:
      failureThreshold: 24
      httpGet:
        host: 10.10.10.2
        path: /health
        port: 2381
        scheme: HTTP
      initialDelaySeconds: 10
      periodSeconds: 10
      timeoutSeconds: 15

@fabriziopandini
Copy link
Member

@maximsnezhkov, question for my better understanding, "http://{{ ds.meta_data.local_ipv4 }}:2381" seems using a templating solution. What is the component responsible for resolving such template variables in your pipeline?

@fabriziopandini
Copy link
Member

/area control-plane
/milestone v0.4.0

@k8s-ci-robot k8s-ci-robot added the area/control-plane Issues or PRs related to control-plane lifecycle management label Dec 16, 2020
@k8s-ci-robot k8s-ci-robot added this to the v0.4.0 milestone Dec 16, 2020
@maximsnezhkov
Copy link
Author

@fabriziopandini {{ ds.meta_data.local_ipv4 }} is a variable from instance cloud-init's facts. I don't know the way how but kubeadm controlPlane provider using it. As an example look at https://github.com/kubernetes-sigs/cluster-api/blob/master/docs/book/src/tasks/kubeadm-bootstrap.md and clusterctl config offers the same kind of variables for me

$ clusterctl config cluster maxim-test --config ./clusterctl.yaml --infrastructure vsphere | grep ds.meta_data
        name: '{{ ds.meta_data.hostname }}'
        name: '{{ ds.meta_data.hostname }}'
    - hostname "{{ ds.meta_data.hostname }}"
    - echo "127.0.0.1   {{ ds.meta_data.hostname }}" >>/etc/hosts
    - echo "{{ ds.meta_data.hostname }}" >/etc/hostname
          name: '{{ ds.meta_data.hostname }}'
      - hostname "{{ ds.meta_data.hostname }}"
      - echo "127.0.0.1   {{ ds.meta_data.hostname }}" >>/etc/hosts
      - echo "{{ ds.meta_data.hostname }}" >/etc/hostname

@fabriziopandini
Copy link
Member

fabriziopandini commented Dec 16, 2020

Ahh, you are right!
So, the problem here is that you are setting this value in ClusterConfiguration, and cluster configuration is generated only on the first control plane node, so it gets templated only one time.

The underlying problem is that kubeadm currently doesn't support node-specific configurations for control plane components (and etcd) via its own configuration API. Also, currently in CABPK/KCP, there is no way to use kubeadm patches, so this problem is tricky to be addressed

So, as for now, the only workaround I can think of is to use a postkubeadm command to alter generated manifests, but long term hopefully this should be properly addressed in kubeadm...

@maximsnezhkov
Copy link
Author

Thanks for quick explanation!
I will use one of the possible workarounds. Do we need to keep this issue open?

@fabriziopandini
Copy link
Member

/close

feel free to re-open if you need more help

@k8s-ci-robot
Copy link
Contributor

@fabriziopandini: Closing this issue.

In response to this:

/close

feel free to re-open if you need more help

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@fabriziopandini
Copy link
Member

Added kubernetes/kubeadm#2367 to kick off the discussion on the kubeadm side

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/control-plane Issues or PRs related to control-plane lifecycle management kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

3 participants