Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

feat: default extra SANs for docker for a working cluster #20

Open
wants to merge 83 commits into
base: main
Choose a base branch
from

Conversation

faiq
Copy link

@faiq faiq commented Apr 1, 2024

No description provided.

jimmidyson and others added 30 commits March 21, 2024 12:30
Missed when reorganising example kustomizations in previous PR.
- Defines a cluster-level variable for defining one or more users
- Patches bootstrap templates for control plane and worker node pools
  with user configuration
Co-authored-by: Faiq <faiq.raza@nutanix.com>
Signed-off-by: Deepak Muley <deepak.muley@nutanix.com>
Without this, defaults declared in the JSON schema are not included in validation
steps, which can lead to invalid failures, while also not allowing for tests that
target defaults.
Fix typo in lockPassword logic, and add unit test
feat: Add examples for Nutanix provider
Add unit test for empty hashed password
Change Sudo field from pointer to value

The zero value (empty string) is not valid, so the field does not need
to be a pointer.
Explain why we do not validate hashed password input
Explain why we do not validate sudo input
Also deploy infra provider versions that match the API.
CPI is a term unique to the vSphere CCM.
Renaming to the more generic "CCM".
@faiq faiq force-pushed the faiq/docker-extra-sans branch 2 times, most recently from 9d6b755 to c5aa24e Compare April 1, 2024 19:04
if err := h.client.Get(ctx, clusterKey, cluster); err != nil {
return err
}
defaultAPICertSANs := getDefaultAPIServerSANs(cluster)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC from the call last week, we wanted to also set defaults in the API either here (if we get the required info of what infra provider it is) or here, that way it shows up if the user doesn't set anything.
We also talked about adding the defaults in the handler as you have here so that the user doesn't need also worry about the defaults and break the cluster.

Copy link
Author

@faiq faiq Apr 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this would be a "add defaults in handler" scenario because the wrong settings or not including these could break the cluster, which would need to be done in the handler.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about this some more, I wonder if we are working around the limitation of not having a mutating webhook.

What we want is to show in the API what values are being set.
Setting it in openapi schema works for defaults, but then when a user overrides it we get these implicit defaults getting added in the handler then then doesn't show up in the Cluster object.

Should we finally work on adding the webhook? It would help with this work and other similar scenarios.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! this should definitely be a webhook, but I think that requires a bigger scope than this.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting it in openapi schema works for defaults, but then when a user overrides it we get these implicit defaults getting added in the handler then then doesn't show up in the Cluster object

Can you please explain a bit further? what needed to show up in Cluster object ? Wont extra SANs will be updated in KubeadmControlPlaneTemplate when the mutator adds them?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for talking with me and explaining how webhook could work.

dkoshkin and others added 2 commits April 2, 2024 15:30
* docs: use an env for KUBERNETES_VERSION

* docs: use a more widely available Kubernetes version

Makes the command more copy-paste friendly.
Kubernetes v1.28.7 is supported here by Docker, AWS and CAPX.
* fix: added support for capx

* refactor: reuse existing CAPX types

* fix: set allowed enums for Nutanix resource types

* fix: set required for Nutanix node type

* fix: reuse resource.Quantity types

* fix: set defaults and validation

* fix: rename field to subnets

* refactor: fix handlers after API changes

* test: add new unit tests

* refactor: bring back host instead of address

* fix: examples with updated APIs

* fix: using latest capx private brach to test kube-vip fix

* fix: set namespace for credentialRef

The patch failed with the following error:
got failure response with message failed to apply JSON patches to input:
replace operation does not apply:
doc is missing key:
/spec/template/spec/prismCentral/credentialRef/namespace: missing value.

* docs: fix users example

* docs: deploying Calico for Nutanix

* fix: added basic docs for nutanix mutations

* fix: lint related fixes

* docs: minor changes

---------

Co-authored-by: Dimitri Koshkin <dimitri.koshkin@nutanix.com>
@faiq faiq self-assigned this Apr 4, 2024
* refactor: use a string type for Nutanix's AdditionalTrustBundle

Use a string instead of a ConfigMap reference
to make it easier for both the handlers to use, and the clients to set in the API.

* fix: force insecure: false with additionalTrustBundle
@supershal
Copy link

WDYT of creating new separate patch dockerExtraAPIServerCertSANsPatch for Docker MetaVariable. Ensure that both lifecycle patch extraAPIServerCertSANsPatch and docker patchdockerExtraAPIServerCertSANsPatch preserves existing list of certSANs.
i.e. something like

for extraAPIServerCertSANsPatch

obj.Spec.Template.Spec.KubeadmConfigSpec.ClusterConfiguration.APIServer.CertSANs = append(obj.Spec.Template.Spec.KubeadmConfigSpec.ClusterConfiguration.APIServer.CertSANs, extraSANsFromVaraiable)

for dockerExtraAPIServerCertSANsPatch

obj.Spec.Template.Spec.KubeadmConfigSpec.ClusterConfiguration.APIServer.CertSANs = append(obj.Spec.Template.Spec.KubeadmConfigSpec.ClusterConfiguration.APIServer.CertSANs, dockerDefaultSANs)

faiq and others added 8 commits April 4, 2024 14:19
* test: unit test for individual patch generator

* test: package level unit test for HTTPProxy

* test: fix data race between multiple unit test that use envtest

* test: make patchgenerator generic function

* fix: linting errors after rebase from main
* test: unit test for individual patch generator

* test: package level unit test for HTTPProxy

* test: move region and httpproxy patch generator unit test invocation

* fix: linting errors

* test: move all AWS patch unit tests to their own packages (#24)

* test: move instanceprofile tests to its own package

* test: move instancetype unit tests to its own package

* test: move ami unit tests to its own package

* test: move aws network tests to its own package

* test: move controlplaneloadbalancer unit tests to its own package

* test: move aws cni unit tests to its own package

* test: fix linting errors

* test: unit tests for AWS security groups

* test: move customimage unit tests to their own package (#30)

* test:  move all Nutanix patch handler unit tests (#32)

* test: move controlplane endpoint unit tests

* test: move PC endpoint unit tests

* test: nove machinedetails unit tests

* test: move generic patch unit tests to own packages (#31)

* test: move audit policy tests to their own package

* test: move etcd unit tests to their own package

* test: move extra api server cert sans to its own package

* test: move image registry unit tests to its own package

* test: move kubernetes image repository unit tests

* test: move mirror unit tests

* test: move users unit tests

* test: remove gereric unit tests from nutanix meta patch handler

* test: cleaned up meta level unit test suites
* feat: Make containerd restart its own patch

* fix: unit tests for kubeadmconfigtemplate with containerdrestart patch

* fix: add comment for always add containerd patch

* test: move unit test to their own package

---------

Co-authored-by: Shalin Patel <shalin.patel@nutanix.com>
@faiq faiq force-pushed the faiq/docker-extra-sans branch from 8365401 to 2866602 Compare April 8, 2024 19:32
@supershal
Copy link

WDYT of creating new separate patch dockerExtraAPIServerCertSANsPatch for Docker MetaVariable. Ensure that both lifecycle patch extraAPIServerCertSANsPatch and docker patchdockerExtraAPIServerCertSANsPatch preserves existing list of certSANs. i.e. something like

A bit more details: I think it would be cleaner to have provider specific logic in the provider's handler. i.e. pkg/handlers/docker/mutation and generic handlers can be free of any logic that is based on provider. Having a docker mutator that always adds default SANs could be cleaner IMHO

@faiq faiq closed this Apr 8, 2024
@faiq faiq reopened this Apr 11, 2024
@faiq
Copy link
Author

faiq commented Apr 11, 2024

WDYT of creating new separate patch dockerExtraAPIServerCertSANsPatch for Docker MetaVariable. Ensure that both lifecycle patch extraAPIServerCertSANsPatch and docker patchdockerExtraAPIServerCertSANsPatch preserves existing list of certSANs. i.e. something like

A bit more details: I think it would be cleaner to have provider specific logic in the provider's handler. i.e. pkg/handlers/docker/mutation and generic handlers can be free of any logic that is based on provider. Having a docker mutator that always adds default SANs could be cleaner IMHO

I disagree. I think adding another handler that touches the same exact fields on objects can be more prone to errors and harder for a developer to discover what gets applied when

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants