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

Parameterize gcr, quay, and docker image repo defines #5146

Merged
merged 1 commit into from
Sep 18, 2019
Merged

Parameterize gcr, quay, and docker image repo defines #5146

merged 1 commit into from
Sep 18, 2019

Conversation

qingkunl
Copy link
Contributor

@qingkunl qingkunl commented Sep 6, 2019

This allows to easily override the gcr, quay, and docker repos with the
mirror repos in countries like China, where the default accesses are
blocked or unstable.

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change
/kind bug
/kind cleanup
/kind design
/kind documentation
/kind failing-test

/kind feature

/kind flake

What this PR does / why we need it:

Allows to use ansible variables to define gcr, quay, and docker repos, so that people can easily override them (e.g. with the mirror repos) in the inventory file. This is very useful for Kubespray users in countries like China, where the access to gcr, quay, and docker repos are blocked or unstable.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

I've tested this change locally on the machines in China. Without this change, the gcr, quay, and docker images couldn't not be downloaded.

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot
Copy link
Contributor

Welcome @qingkunl!

It looks like this is your first PR to kubernetes-sigs/kubespray 🎉. 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/kubespray 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

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Sep 6, 2019
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Sep 6, 2019
@qingkunl
Copy link
Contributor Author

qingkunl commented Sep 6, 2019

/assign @woopstar

@qingkunl
Copy link
Contributor Author

qingkunl commented Sep 6, 2019

/retest

@k8s-ci-robot
Copy link
Contributor

@qingkunl: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

Copy link
Contributor

@mirwan mirwan left a comment

Choose a reason for hiding this comment

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

Unless I'm wrong images from docker hub could benefit from the same variable with "docker.io" as default.

@qingkunl
Copy link
Contributor Author

qingkunl commented Sep 7, 2019

Unless I'm wrong images from docker hub could benefit from the same variable with "docker.io" as default.

It's true that "docker.io" is blocked in China. But we've already got ways to specify the docker mirror by overriding 'docker_registry_mirrors' defined in 'roles/kubespray-defaults/defaults/main.yaml':

## A list of additional registry mirrors, for example China registry mirror. Empty by default.
# docker_registry_mirrors:
#   - https://registry.docker-cn.com
#   - https://mirror.aliyuncs.com
docker_registry_mirrors: []

@mirwan
Copy link
Contributor

mirwan commented Sep 7, 2019

docker_registry_mirrors is only used if docker is used as container runtime, with containerd for example, some images for docker.io get pulled

@mirwan
Copy link
Contributor

mirwan commented Sep 7, 2019

Have the same variable for docker.io as for gcr.io and qua.ioy would ease the overridings of all *_image_repo variables in offline installations as well

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 8, 2019
@qingkunl qingkunl changed the title Parameterize gcr and quay image repo defines Parameterize gcr, quay, and docker image repo defines Sep 8, 2019
@Timoses
Copy link
Contributor

Timoses commented Sep 8, 2019

Why not use something like the following:

roles/download/defaults/main.yml

downloads:
  cilium:
    enabled: "{{ kube_network_plugin == 'cilium' }}"
    container: true
    repo: docker.io/cilium/cilium
    tag: "{{ cilium_version }}"
    sha256: "{{ cilium_digest_checksum|default(None) }}"
    groups:
      - k8s-cluster

User then wants to use another registry:

downloads_overrides:
  cilium:
    repo: mycustomregistry.io/myproject/cilium

Then roles/download/tasks/main.yml would use

downloads | combine(downloads_overrides)

This would get rid of all the *_image_repo and *_image_tag variables while allowing the user to specify which download should be adjusted.

Additionally, it would be possible to use:

downloads:
  cilium:
    repo: "{{ downloads_image_registry | default('docker.io/cilium/cilium') }}"

in case the user wants to use a single registry.

Note: Be aware that the download role has a dynamic part:

- name: download | Get kubeadm binary and list of required images

@qingkunl
Copy link
Contributor Author

qingkunl commented Sep 8, 2019

@mirwan That makes sense. I've updated the PR to add the variable for "docker.io" as well. Thanks.

@qingkunl
Copy link
Contributor Author

qingkunl commented Sep 8, 2019

Why not use something like the following:

roles/download/defaults/main.yml

downloads:
  cilium:
    enabled: "{{ kube_network_plugin == 'cilium' }}"
    container: true
    repo: docker.io/cilium/cilium
    tag: "{{ cilium_version }}"
    sha256: "{{ cilium_digest_checksum|default(None) }}"
    groups:
      - k8s-cluster

User then wants to use another registry:

downloads_overrides:
  cilium:
    repo: mycustomregistry.io/myproject/cilium

Then roles/download/tasks/main.yml would use

downloads | combine(downloads_overrides)

This would get rid of all the *_image_repo and *_image_tag variables while allowing the user to specify which download should be adjusted.

Additionally, it would be possible to use:

downloads:
  cilium:
    repo: "{{ downloads_image_registry | default('docker.io/cilium/cilium') }}"

in case the user wants to use a single registry.

Note: Be aware that the download role has a dynamic part:

- name: download | Get kubeadm binary and list of required images

Thanks for the suggestion. But it doesn't solve the problem I'm trying to solve in this PR. I'd like to be able to just override the repo for all gcr/quay/docker images with a simple repo override (so that I can easily use mirror repos), instead of having to go through and override each image (etcd, cilium, dashboard, nodelocaldns, etc.).

Copy link
Contributor

@mirwan mirwan left a comment

Choose a reason for hiding this comment

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

The images repos with no namespace should have the library namespace added like nginx_image_repo: "{{ docker_image_repo }}/library/nginx"

@qingkunl
Copy link
Contributor Author

qingkunl commented Sep 9, 2019

The images repos with no namespace should have the library namespace added like nginx_image_repo: "{{ docker_image_repo }}/library/nginx"

Updated the PR to add library namespace. Thanks

@mirwan
Copy link
Contributor

mirwan commented Sep 9, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 9, 2019
@qingkunl
Copy link
Contributor Author

It's been silent for a while. Anything else I should do here?

kube_ovn_cni_image_repo: "docker.io/kubeovn/kube-ovn-cni"
kube_ovn_db_image_repo: "{{ docker_image_repo }}/kubeovn/kube-ovn-db"
kube_ovn_node_image_repo: "{{ docker_image_repo }}/kubeovn/kube-ovn-node"
kube_ovn_cni_image_repo: "{{ docker_image_repo }}/kubeovn/kube-ovn-cni"
kube_ovn_controller_image_repo: "kubeovn/kube-ovn-controller"
Copy link
Contributor

Choose a reason for hiding this comment

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

{{ docker_image_repo }}/kubeovn/kube-ovn-controller
I think this needs to be fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in the latest commit

@riverzhang riverzhang closed this Sep 17, 2019
@riverzhang riverzhang reopened this Sep 17, 2019
@riverzhang
Copy link
Contributor

Have the same variable for docker.io as for gcr.io and qua.ioy would ease the overridings of all *_image_repo variables in offline installations as well

I agree with this approach, otherwise users will have a lot of configuration options.
@qingkunl in case the user wants to use a single registry. This is very useful for Chinese users, or harbor users. I think @Timoses 's suggestion can be considered,What do you think?

@riverzhang
Copy link
Contributor

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 17, 2019
This allows to easily override the gcr, quay, and docker repos with the
mirror repos in countries like China, where the default accesses are
blocked or unstable.
@qingkunl
Copy link
Contributor Author

Have the same variable for docker.io as for gcr.io and qua.ioy would ease the overridings of all *_image_repo variables in offline installations as well

I agree with this approach, otherwise users will have a lot of configuration options.

I think @mirwan meant to also define a variable for docker.io, as I originally only defined variables for gcr.io and quay.io, and I've already done that. Please let me know if I misunderstood.

@qingkunl in case the user wants to use a single registry. This is very useful for Chinese users, or harbor users. I think @Timoses 's suggestion can be considered,What do you think?

It may not help much in my case, as I need to override all images with the mirror repos and don't want to go through and override each of them (etcd, cilium, dashboard, nodelocaldns, etc.). In addition, since it requires a more involved code change and refactor, I suggest consider it in a separate PR. And in case we do want @Timoses 's suggestion, I still suggest keeping this PR to allow the mirror repo override.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 18, 2019
@riverzhang
Copy link
Contributor

@qingkunl Thanks,
/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 Sep 18, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qingkunl, riverzhang

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 Sep 18, 2019
@riverzhang
Copy link
Contributor

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 18, 2019
@k8s-ci-robot k8s-ci-robot merged commit 3c7f682 into kubernetes-sigs:master Sep 18, 2019
erulabs added a commit to kubesail/kubespray that referenced this pull request Sep 18, 2019
* 'master' of https://github.com/kubernetes-sigs/kubespray:
  Add support for k8s v1.14.6 (kubernetes-sigs#5182)
  Parameterize gcr, quay, and docker image repo defines (kubernetes-sigs#5146)
  use hyperkubeimage to run controlplane containers (kubernetes-sigs#5178)
  Update main.yml (kubernetes-sigs#5166)
  Fixes issue kubernetes-sigs#5160 (kubernetes-sigs#5171)
  Use more native way to update kubeconfigs using kubeadm (kubernetes-sigs#5165)
  Fix macro on local_volume_provisioner (kubernetes-sigs#5168)
  Move cri_socket var to kubespray-defaults (kubernetes-sigs#5149)
  Add support for k8s v1.16.0-beta.2 (kubernetes-sigs#5148)
  Fix ansible task titles (kubernetes-sigs#5154)
  Adjust endpoints for kube-proxy,controller,scheduler to proper ip (kubernetes-sigs#5150)
  Documenting Terraform variable `az_list` explicitly (kubernetes-sigs#5132)
  Make haproxy/nginx client timeout configurable (kubernetes-sigs#5140)
  print hostnames (kubernetes-sigs#5110)
  Cleanup: fix typo in doc (kubernetes-sigs#5105)
  Use python3-libselinux on RHEL8/Centos8 (kubernetes-sigs#5127)
LuckySB pushed a commit to southbridgeio/kubespray that referenced this pull request Dec 8, 2019
…s#5146)

This allows to easily override the gcr, quay, and docker repos with the
mirror repos in countries like China, where the default accesses are
blocked or unstable.
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. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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.

6 participants