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

feat: add kube-vip static Pod in a Nutanix handler #558

Merged
merged 11 commits into from
Apr 26, 2024

Conversation

dkoshkin
Copy link
Contributor

@dkoshkin dkoshkin commented Apr 23, 2024

What problem does this PR solve?:
Stacked on #554

This PR moves the responsibility of adding the control-plan kube-vip to CAREN away from infra providers.
This has a big benefit of being able to keep this implementation and the image version consistent across the different providers.

Because CAPX is always requires kube-vip to be installed there are no API changes, but in the future we can add support to disable or change the provider.
Added an empty virtualIP{} struct to Nutanix controlPlaneEndpoint.

spec:
  topology:
    variables:
      - name: clusterConfig
        value:
          nutanix:
            controlPlaneEndpoint:
              host: x.x.x.x
              port: 6443
              virtualIP: {}

Which issue(s) this PR fixes:
Fixes https://jira.nutanix.com/browse/D2IQ-100364

How Has This Been Tested?:

New unit tests, and tested manually too:

clusterctl describe cluster $CLUSTER_NAME    
NAME                                                                                              READY  SEVERITY  REASON  SINCE  MESSAGE 
Cluster/dkkonvoy-042324-nutanix-03                                                                True                     76m             
├─ClusterInfrastructure - NutanixCluster/dkkonvoy-042324-nutanix-03-wvv6d                                                                  
├─ControlPlane - KubeadmControlPlane/dkkonvoy-042324-nutanix-03-sv2zb                             True                     76m             
│ └─Machine/dkkonvoy-042324-nutanix-03-sv2zb-ds5mv                                                True                     76m             
│   └─MachineInfrastructure - NutanixMachine/dkkonvoy-042324-nutanix-03-sv2zb-ds5mv                                                        
└─Workers                                                                                                                                  
  └─MachineDeployment/dkkonvoy-042324-nutanix-03-md-0-w6mls                                       True                     74m             
    └─Machine/dkkonvoy-042324-nutanix-03-md-0-w6mls-979mw-c582s                                   True                     74m             
      └─MachineInfrastructure - NutanixMachine/dkkonvoy-042324-nutanix-03-md-0-w6mls-979mw-c582s                                      

Special notes for your reviewer:

@jimmidyson
Copy link
Member

Because CAPX always requires kube-vip to be installed

Is this true? Is there no way a customer could deploy a different load balancer for this? Should this be opt-in (but default true in our templates so effectively opt-out)?

@dkoshkin
Copy link
Contributor Author

Because CAPX always requires kube-vip to be installed

Is this true? Is there no way a customer could deploy a different load balancer for this? Should this be opt-in (but default true in our templates so effectively opt-out)?

We just got some feedback from an existing customer that is using an external LB where kube-vip would not be needed.
I will update this PR and put it behind an API that defaults to enabled and kube-vip provider.

@deepakm-ntnx
Copy link
Contributor

@dkoshkin did this work with k8s 1.29.x?

@dkoshkin
Copy link
Contributor Author

@dkoshkin did this work with k8s 1.29.x?

Good question, the pre/postKubeadmCommands are still in the templates so it should but let me try that.

@dkoshkin
Copy link
Contributor Author

Tested with both Kubernetes v1.28

NAME                                                                                                 READY  SEVERITY  REASON  SINCE  MESSAGE                                                                                       
Cluster/dkkonvoy-042424-nutanix-128-2                                                                True                     31s                                                                                                   
├─ClusterInfrastructure - NutanixCluster/dkkonvoy-042424-nutanix-128-2-bc7z9                                                                                                                                                        
├─ControlPlane - KubeadmControlPlane/dkkonvoy-042424-nutanix-128-2-9mrkj                             True                     31s                                                                                                   
│ └─3 Machines...                                                                                    True                     3m22s  See dkkonvoy-042424-nutanix-128-2-9mrkj-hphdt, dkkonvoy-042424-nutanix-128-2-9mrkj-ktxjs, ...  
└─Workers                                                                                                                                                                                                                           
  └─MachineDeployment/dkkonvoy-042424-nutanix-128-2-md-0-mnm7c                                       True                     2m8s                                                                                                  
    └─Machine/dkkonvoy-042424-nutanix-128-2-md-0-mnm7c-qmwq8-bf7mx                                   True                     2m52s                                                                                                 
      └─MachineInfrastructure - NutanixMachine/dkkonvoy-042424-nutanix-128-2-md-0-mnm7c-qmwq8-bf7mx                                                                                                                                 


NAME                                                   CLUSTER                         NODENAME                                               PROVIDERID                                       PHASE     AGE     VERSION
dkkonvoy-042424-nutanix-128-2-9mrkj-hphdt              dkkonvoy-042424-nutanix-128-2   dkkonvoy-042424-nutanix-128-2-9mrkj-hphdt              nutanix://063a872a-fab1-4121-8692-c6a42cbaf75b   Running   71s     v1.28.7
dkkonvoy-042424-nutanix-128-2-9mrkj-ktxjs              dkkonvoy-042424-nutanix-128-2   dkkonvoy-042424-nutanix-128-2-9mrkj-ktxjs              nutanix://f1453c2b-4199-48e2-bc9b-80a312f34a98   Running   3m47s   v1.28.7
dkkonvoy-042424-nutanix-128-2-9mrkj-pm77z              dkkonvoy-042424-nutanix-128-2   dkkonvoy-042424-nutanix-128-2-9mrkj-pm77z              nutanix://af8d6dd7-8edb-4762-9c32-3de93c0ddb6f   Running   2m27s   v1.28.7
dkkonvoy-042424-nutanix-128-2-md-0-mnm7c-qmwq8-bf7mx   dkkonvoy-042424-nutanix-128-2   dkkonvoy-042424-nutanix-128-2-md-0-mnm7c-qmwq8-bf7mx   nutanix://23cb029f-f783-4c75-be6c-bd37c9bf8f6e   Running   3m50s   v1.28.7


      postKubeadmCommands:
      - echo export KUBECONFIG=/etc/kubernetes/admin.conf >> /root/.bashrc
      - echo "after kubeadm call" > /var/log/postkubeadm.log
      preKubeadmCommands:
      - echo "before kubeadm call" > /var/log/prekubeadm.log
      - hostnamectl set-hostname "{{ ds.meta_data.hostname }}"
      - echo "::1         ipv6-localhost ipv6-loopback" >/etc/hosts
      - echo "127.0.0.1   localhost" >>/etc/hosts
      - echo "127.0.0.1   kubernetes" >>/etc/hosts
      - echo "127.0.0.1   {{ ds.meta_data.hostname }}" >> /etc/hosts
      - /bin/bash /etc/cre/install-kubelet-credential-providers.sh
      - /bin/bash /etc/containerd/restart.sh

And v1.29

NAME                                                                                                 READY  SEVERITY  REASON  SINCE  MESSAGE                                                                                       
Cluster/dkkonvoy-042424-nutanix-129-7                                                                True                     8m43s                                                                                                 
├─ClusterInfrastructure - NutanixCluster/dkkonvoy-042424-nutanix-129-7-pwzt5                                                                                                                                                        
├─ControlPlane - KubeadmControlPlane/dkkonvoy-042424-nutanix-129-7-7mvfv                             True                     8m43s                                                                                                 
│ └─3 Machines...                                                                                    True                     10m    See dkkonvoy-042424-nutanix-129-7-7mvfv-2vj6x, dkkonvoy-042424-nutanix-129-7-7mvfv-b2g4p, ...  
└─Workers                                                                                                                                                                                                                           
  └─MachineDeployment/dkkonvoy-042424-nutanix-129-7-md-0-9wfdz                                       True                     9m16s                                                                                                 
    └─Machine/dkkonvoy-042424-nutanix-129-7-md-0-9wfdz-5mnjp-zf5rd                                   True                     10m                                                                                                   
      └─MachineInfrastructure - NutanixMachine/dkkonvoy-042424-nutanix-129-7-md-0-9wfdz-5mnjp-zf5rd                                                                                                                                 


NAME                                                   CLUSTER                         NODENAME                                               PROVIDERID                                       PHASE     AGE     VERSION
dkkonvoy-042424-nutanix-129-7-7mvfv-2vj6x              dkkonvoy-042424-nutanix-129-7   dkkonvoy-042424-nutanix-129-7-7mvfv-2vj6x              nutanix://ac70a906-76fe-4e5a-b10e-22253abc356d   Running   10m     v1.29.2
dkkonvoy-042424-nutanix-129-7-7mvfv-b2g4p              dkkonvoy-042424-nutanix-129-7   dkkonvoy-042424-nutanix-129-7-7mvfv-b2g4p              nutanix://57d8d55f-fb18-4e2d-9089-b76f1e79e433   Running   11m     v1.29.2
dkkonvoy-042424-nutanix-129-7-7mvfv-m52br              dkkonvoy-042424-nutanix-129-7   dkkonvoy-042424-nutanix-129-7-7mvfv-m52br              nutanix://98320226-0e9b-4c2c-82a8-b327ae8ce00f   Running   9m18s   v1.29.2
dkkonvoy-042424-nutanix-129-7-md-0-9wfdz-5mnjp-zf5rd   dkkonvoy-042424-nutanix-129-7   dkkonvoy-042424-nutanix-129-7-md-0-9wfdz-5mnjp-zf5rd   nutanix://62c16adb-780c-48e6-9473-646e016d2763   Running   12m     v1.29.2

      postKubeadmCommands:
      - echo export KUBECONFIG=/etc/kubernetes/admin.conf >> /root/.bashrc
      - echo "after kubeadm call" > /var/log/postkubeadm.log
      - |-
        if [ -f /run/kubeadm/kubeadm.yaml ]; then
          sed -i 's#path: /etc/kubernetes/super-admin.conf#path: /etc/kubernetes/admin.conf#' /etc/kubernetes/manifests/kube-vip.yaml;
        fi
      preKubeadmCommands:
      - echo "before kubeadm call" > /var/log/prekubeadm.log
      - hostnamectl set-hostname "{{ ds.meta_data.hostname }}"
      - echo "::1         ipv6-localhost ipv6-loopback" >/etc/hosts
      - echo "127.0.0.1   localhost" >>/etc/hosts
      - echo "127.0.0.1   kubernetes" >>/etc/hosts
      - echo "127.0.0.1   {{ ds.meta_data.hostname }}" >> /etc/hosts
      - |-
        if [ -f /run/kubeadm/kubeadm.yaml ]; then
          sed -i 's#path: /etc/kubernetes/admin.conf#path: /etc/kubernetes/super-admin.conf#' /etc/kubernetes/manifests/kube-vip.yaml;
        fi
      - /bin/bash /etc/cre/install-kubelet-credential-providers.sh
      - /bin/bash /etc/containerd/restart.sh

@dkoshkin
Copy link
Contributor Author

dkoshkin commented Apr 25, 2024

Thanks @deepakm-ntnx for the 1.29 question, it made me realize that CAREN should also be responsible for adding the commands, done in e278d2b

I did test without this commit and it didn't work because it expects KUBERNETES_VERSION to be set to a value.
I will fix the CAPX templates to be more generic and instead only apply this patch based on the built in variable .builtin.controlPlane.version.

@dkoshkin dkoshkin force-pushed the dkoshkin/feat-kube-vip branch 2 times, most recently from 39621fe to 3b62fdd Compare April 25, 2024 03:24
@dkoshkin
Copy link
Contributor Author

Tested with the latest changes after rebase

NAME                                                                                                 READY  SEVERITY  REASON  SINCE  MESSAGE                                                                                       
Cluster/dkkonvoy-042524-nutanix-128-1                                                                True                     36s                                                                                                   
├─ClusterInfrastructure - NutanixCluster/dkkonvoy-042524-nutanix-128-1-w9grt                                                                                                                                                        
├─ControlPlane - KubeadmControlPlane/dkkonvoy-042524-nutanix-128-1-pxzp4                             True                     36s                                                                                                   
│ └─3 Machines...                                                                                    True                     2m     See dkkonvoy-042524-nutanix-128-1-pxzp4-jpbkp, dkkonvoy-042524-nutanix-128-1-pxzp4-k86kz, ...  
└─Workers                                                                                                                                                                                                                           
  └─MachineDeployment/dkkonvoy-042524-nutanix-128-1-md-0-fwksc                                       True                     106s                                                                                                  
    └─Machine/dkkonvoy-042524-nutanix-128-1-md-0-fwksc-np89s-kb94k                                   True                     2m1s                                                                                                  
      └─MachineInfrastructure - NutanixMachine/dkkonvoy-042524-nutanix-128-1-md-0-fwksc-np89s-kb94k                                                                                                                                 

api/v1alpha1/common_types.go Outdated Show resolved Hide resolved
dkoshkin and others added 3 commits April 26, 2024 10:58
The kube-vip repo uses this format
Co-authored-by: Shalin Patel <shalin.patel@nutanix.com>
@jimmidyson jimmidyson merged commit cbd401f into main Apr 26, 2024
16 checks passed
@jimmidyson jimmidyson deleted the dkoshkin/feat-kube-vip branch April 26, 2024 20:07
@github-actions github-actions bot mentioned this pull request Apr 26, 2024
faiq pushed a commit that referenced this pull request Apr 29, 2024
🤖 I have created a release *beep* *boop*
---


## 0.8.0 (2024-04-29)

<!-- Release notes generated using configuration in .github/release.yaml
at main -->

## What's Changed
### Exciting New Features 🎉
* feat: give mutators a clusterGetter function by @faiq in
https://github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pull/514it was unintelliga
* feat: get default sans via cluster object in patch handler for docker
by @faiq in
#519
* feat: adds nutanix SANs via patchHandler by @faiq in
#522
* feat: nutanix csi driver 3.0 by @faiq in
#531
* feat: Add additionalCategories field to Nutanix machine details patch
by @dlipovetsky in
#525
* feat: support setting Nutanix project on machines by @dkoshkin in
#535
* feat: Upgrade to CAPI v1.7.0 by @jimmidyson in
#555
* feat: CAPI v1.7.1 by @jimmidyson in
#560
* feat: Preserve user-managed fields when applying resources by
@dlipovetsky in
#556
* feat: Preserve user-managed fields when creating namespace by
@dlipovetsky in
#557
* feat: Added e2e test for capx cluster by @deepakm-ntnx in
#523
* feat: add kube-vip static Pod in a Nutanix handler by @dkoshkin in
#558
* feat: AWS CCM for Kubernetes v1.29 by @dkoshkin in
#564
### Fixes 🔧
* fix: updated the capx version used by @deepakm-ntnx in
#513
* fix: add omitempty to CCM Credentials struct by @dkoshkin in
#524
* fix: Add specific descriptions to Nutanix machine details fields by
@dlipovetsky in
#532
* refactor: setting ownership references to Nutanix CSI Helm Chart
Proxies by @dlipovetsky in
#565
### Other Changes
* build: Specify go1.22.2 as toolchain to fix govulncheck issues by
@jimmidyson in
#517
* build: Add metadata for latest v0.7.0 release by @jimmidyson in
#515
* refactor: Consistently import CAPI v1beta1 package as clusterv1 alias
by @jimmidyson in
#518
* build: Fix image tags in release manifests by @jimmidyson in
#516
* test(e2e): Use same versions of providers from module dependencies by
@jimmidyson in
#521
* build: update aws credentials on kind bootstrap cluster by @supershal
in
#507
* refactor: standardize the code for getting Helm values by @dkoshkin in
#500
* build: Use latest k8s for dev and test management cluster by
@jimmidyson in
#526
* docs: Add how to release doc by @jimmidyson in
#530
* build: adds a .envrc.local file for local development for dotenv by
@faiq in
#538
* refactor: create storage classes directly instead of using CRS by
@faiq in
#539
* refactor: Move API to caren.nutanix.com group by @jimmidyson in
#534
* build: Add Kubernetes v1.30.0 option for bootstrap and Docker provider
by @jimmidyson in
#541
* build: create .envrc.e2e file from caren e2e config by @supershal in
#540
* build: Only allow patch updates to k8s libs by @jimmidyson in
#551
* build: Generate CRD YAML by @jimmidyson in
#536
* build: Minor golangci-lint config updates for recent versions by
@jimmidyson in
#552
* build: generated CRDs yamls by @dkoshkin in
#553
* refactor: Use separate types for provider cluster configs by
@jimmidyson in
#537
* docs: Remove additionalCategories from required fields by @dlipovetsky
in
#543
* build: Upgrade tooling, notably go to v1.22.2 by @jimmidyson in
#561
* refactor: provider an entrypoint to the infra provider meta handlers
by @dkoshkin in
#554
* test(e2e): Add self-hosted e2e test by @jimmidyson in
#439
* build: Bundle k8s.io/* back in with sigs.k8s.io/* dependencies by
@jimmidyson in
#583
* build: Add envtest setup to e2e envrc by @jimmidyson in
#563

## New Contributors
* @deepakm-ntnx made their first contribution in
#513

**Full Changelog**:
v0.7.0...v0.8.0

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants