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

✨ Add NodeRegistrationOptions.ImagePullPolicy Support #7772

Merged

Conversation

akshay196
Copy link
Contributor

What this PR does / why we need it:
Add support for ImagePullPolicy in KCP and CABPK.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #6679

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 17, 2022
@k8s-ci-robot
Copy link
Contributor

Welcome @akshay196!

It looks like this is your first PR to kubernetes-sigs/cluster-api 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-api has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @akshay196. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 17, 2022
@akshay196
Copy link
Contributor Author

Hi team,
I am facing some issue testing this PR locally and would like get some suggestions.

  1. I had setup cluster-api up locally using Tilt. New CRD is installed properly, but after I apply a KubeadmControlPlane resource with ImagePullPolicy, somehow it always reverts to IfNotPresent even if I set it something else. Here is an example:
$ kubectl get crd kubeadmcontrolplanes.controlplane.cluster.x-k8s.io -o yaml | grep imagePullPolicy -A10
--
                          imagePullPolicy:
                            default: IfNotPresent
                            description: ImagePullPolicy specifies the policy for
                              image pulling during kubeadm "init" and "join" operations.
                              The value of this field must be one of "Always", "IfNotPresent"
                              or "Never". Defaults to "IfNotPresent".
                            enum:
                            - Always
                            - IfNotPresent
                            - Never
                            type: string
--
                          imagePullPolicy:
                            default: IfNotPresent
                            description: ImagePullPolicy specifies the policy for
                              image pulling during kubeadm "init" and "join" operations.
                              The value of this field must be one of "Always", "IfNotPresent"
                              or "Never". Defaults to "IfNotPresent".
                            enum:
                            - Always
                            - IfNotPresent
                            - Never
                            type: string

$ cat kubeadm-controlplane.yaml
kind: KubeadmControlPlane
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
metadata:
  name: "demo-control-plane"
spec:
  replicas: 1
  machineTemplate:
    infrastructureRef:
      kind: GCPMachineTemplate
      apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
      name: "demo-control-plane"
  kubeadmConfigSpec:
    initConfiguration:
      nodeRegistration:
        imagePullPolicy: Always                                    <-------------------- Set to this
        name: '{{ ds.meta_data.local_hostname.split(".")[0] }}'
        kubeletExtraArgs:
          cloud-provider: gce
    clusterConfiguration:
      apiServer:
        timeoutForControlPlane: 20m
        extraArgs:
          cloud-provider: gce
      controllerManager:
        extraArgs:
          cloud-provider: gce
          allocate-node-cidrs: "false"
    joinConfiguration:
      nodeRegistration:
        imagePullPolicy: Always                               <---------------- Set to this
        name: '{{ ds.meta_data.local_hostname.split(".")[0] }}'
        kubeletExtraArgs:
          cloud-provider: gce
  version: "v1.23.0"

$ kubectl apply -f kubeadm-controlplane.yaml
kubeadmcontrolplane.controlplane.cluster.x-k8s.io/demo-control-plane created

$ kubectl get kubeadmcontrolplane demo-control-plane -o yaml
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: KubeadmControlPlane
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"controlplane.cluster.x-k8s.io/v1beta1","kind":"KubeadmControlPlane","metadata":{"annotations":{},"name":"demo-control-plane","namespace":"default"},"spec":{"kubeadmConfigSpec":{"clusterConfiguration":{"apiServer":{"extraArgs":{"cloud-provider":"gce"},"timeoutForControlPlane":"20m"},"controllerManager":{"extraArgs":{"allocate-node-cidrs":"false","cloud-provider":"gce"}}},"initConfiguration":{"nodeRegistration":{"imagePullPolicy":"Always","kubeletExtraArgs":{"cloud-provider":"gce"},"name":"{{ ds.meta_data.local_hostname.split(\".\")[0] }}"}},"joinConfiguration":{"nodeRegistration":{"imagePullPolicy":"Always","kubeletExtraArgs":{"cloud-provider":"gce"},"name":"{{ ds.meta_data.local_hostname.split(\".\")[0] }}"}}},"machineTemplate":{"infrastructureRef":{"apiVersion":"infrastructure.cluster.x-k8s.io/v1beta1","kind":"GCPMachineTemplate","name":"demo-control-plane"}},"replicas":1,"version":"v1.23.0"}}
  creationTimestamp: "2022-12-17T17:57:16Z"
  generation: 1
  name: demo-control-plane
  namespace: default
  resourceVersion: "88831"
  uid: ffb656da-d89f-4f9a-9401-8e991632806d
spec:
  kubeadmConfigSpec:
    clusterConfiguration:
      apiServer:
        extraArgs:
          cloud-provider: gce
        timeoutForControlPlane: 20m0s
      controllerManager:
        extraArgs:
          allocate-node-cidrs: "false"
          cloud-provider: gce
      dns: {}
      etcd: {}
      networking: {}
      scheduler: {}
    format: cloud-config
    initConfiguration:
      localAPIEndpoint: {}
      nodeRegistration:
        imagePullPolicy: IfNotPresent                 <------------- This has automatically changed
        kubeletExtraArgs:
          cloud-provider: gce
        name: '{{ ds.meta_data.local_hostname.split(".")[0] }}'
    joinConfiguration:
      discovery: {}
      nodeRegistration:
        imagePullPolicy: IfNotPresent                   <------------- This has automatically changed
        kubeletExtraArgs:
          cloud-provider: gce
        name: '{{ ds.meta_data.local_hostname.split(".")[0] }}'
  machineTemplate:
    infrastructureRef:
      apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
      kind: GCPMachineTemplate
      name: demo-control-plane
      namespace: default
    metadata: {}
  replicas: 1
  rolloutStrategy:
    rollingUpdate:
      maxSurge: 1
    type: RollingUpdate
  version: v1.23.0
  1. Any suggestions on how to verify ImagePullPolicy applied successfully for the cluster provisioned?

@akshay196 akshay196 marked this pull request as ready for review January 24, 2023 15:45
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 24, 2023
@sbueringer
Copy link
Member

/ok-to-test

I'll take a look

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 25, 2023
@sbueringer
Copy link
Member

@akshay196

Remaining issues should be:

@sbueringer
Copy link
Member

sbueringer commented Jan 26, 2023

@akshay196 Just fyi. That should be the second part that I described now. (you can generate the conversion with make generate-go-conversions)

@akshay196
Copy link
Contributor Author

akshay196 commented Jan 26, 2023

That should be the second part that I described now. (you can generate the conversion with make generate-go-conversions)

I executed make generate-go-conversions that drop generated convert funcs from v1alpha4 and upstreamv1beta2. Then I manually added convert funcs to conversion.go and again executed make generate-go-convertsions
Is this correct?

@sbueringer
Copy link
Member

sbueringer commented Jan 26, 2023

Yup sounds correct. I never remember if the final make generate-go-conversions is necessary or not.
But looks like the verify job is happy now. So the generated files are okay.

Now we have to take a look at the unit tests. Seems there is an issue with the conversion somewhere (I"ll take a look)

(btw more context here: https://hackmd.io/aYLvrb_jTXiwg_MnpD804w)

@akshay196
Copy link
Contributor Author

akshay196 commented Jan 26, 2023

Yup sounds correct. I never remember if the final make generate-go-conversions is necessary or not.

The final make generate-go-conversions modified AddGeneratedConversionFunc to AddConversionFunc in zz_generated.conversion.go file.

Now we have to take a look at the unit tests. Seems there is an issue with the conversion somewhere (I"ll take a look)
(btw more context here: https://hackmd.io/aYLvrb_jTXiwg_MnpD804w)

Thanks for sharing that. I don't completely understand how conversion happening here. I took reference from PR #4905 and did corresponding changes. I may have made mistakes.
I will refer your link now.

@sbueringer
Copy link
Member

@akshay196 No worries. It's unfortunately quite complex. I added some hints as a comment above. After those changes the tests should be green.

@sbueringer
Copy link
Member

/test pull-cluster-api-e2e-full-main

@akshay196
Copy link
Contributor Author

capi-e2e test is failing with this error:

Failed to get logs for Machine clusterclass-changes-b1puz1-8tc5h-md4df, Cluster clusterclass-changes-n51zp0/clusterclass-changes-b1puz1: error creating container exec: Error response from daemon: Container ffedbb0d2611970c9dddc4255f621d4a0a5c2050b0078fd674fdc756ccaab8d7 is not running
Failed to get logs for Machine clusterclass-changes-b1puz1-md-0-pbtfx-98d6fd966-5ks9r, Cluster clusterclass-changes-n51zp0/clusterclass-changes-b1puz1: error creating container exec: Error response from daemon: No such container: clusterclass-changes-b1puz1-md-0-pbtfx-98d6fd966-5ks9r

Is it some flaky test?

@sbueringer
Copy link
Member

/retest

@sbueringer
Copy link
Member

Probably. Let's see

@sbueringer
Copy link
Member

Another flake :/

/retest

@sbueringer
Copy link
Member

/lgtm

Let's wait for green e2e tests, but then it would be good if you can squash the commits

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 30, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 4251399300b8a52ca787800fe80774c6a0d4af93

Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

one nit, otherwise lgtm for me pending squash

@akshay196 akshay196 force-pushed the add-support-imagepullpolicy branch from 1643f0e to 7ed1548 Compare January 30, 2023 17:26
@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Jan 30, 2023
@akshay196 akshay196 force-pushed the add-support-imagepullpolicy branch from 7ed1548 to 7103f32 Compare January 30, 2023 17:30
Add the `imagePullPolicy` field in the `nodeRegistration` section of
`InitConfiguration` and `JoinConfiguration`. This allows the user to
specify the image pull policy in KCP and CABPK. The value of this
field must be one of `Always`, `IfNotPresent` or `Never`.

Signed-off-by: Akshay Gaikwad <[email protected]>
@akshay196 akshay196 force-pushed the add-support-imagepullpolicy branch from 7103f32 to 4ca79ad Compare January 30, 2023 17:37
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Jan 30, 2023
@akshay196
Copy link
Contributor Author

PR rebased on main and all commits are squashed. 🚀

@sbueringer
Copy link
Member

Thank you very much!!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 30, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 671167c3b3dea77402808730f637f93891e02e66

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 30, 2023
@k8s-ci-robot k8s-ci-robot merged commit 1b61819 into kubernetes-sigs:main Jan 30, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.4 milestone Jan 30, 2023
@akshay196
Copy link
Contributor Author

Thank you @sbueringer @fabriziopandini for reviewing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for ImagePullPolicy in KCP and CABPK
4 participants