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

Support k3s private registry configuration #114

Merged
merged 4 commits into from
May 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ __pycache__
ansible.cfg
pyratlabs-issue-dump.txt
.cache
/.idea/
Copy link
Member

Choose a reason for hiding this comment

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

What's this for?

Copy link
Contributor Author

@anjia0532 anjia0532 May 8, 2021

Choose a reason for hiding this comment

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

work ide env is idea+OrchidE plugin, git clone and import to my workspace will auto create .idea dir.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ consistency. These are generally cluster-level configuration.
| `k3s_use_unsupported_config` | Allow the use of unsupported configurations in k3s. | `false` |
| `k3s_etcd_datastore` | Enable etcd embedded datastore (read notes below). | `false` |
| `k3s_debug` | Enable debug logging on the k3s service. | `false` |
| `k3s_registries` | Registries configuration file content. | `{ mirrors: {}, configs:{} }` |

### K3S Service Configuration

Expand Down
23 changes: 23 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,26 @@ k3s_become_for_usr_local_bin: null
k3s_become_for_package_install: null
k3s_become_for_kubectl: null
k3s_become_for_uninstall: null

# Private registry configuration.
# Rancher k3s documentation: https://rancher.com/docs/k3s/latest/en/installation/private-registry/
k3s_registries:

mirrors:
# docker.io:
# endpoint:
# - "https://mycustomreg.com:5000"
configs:
# "mycustomreg:5000":
# auth:
# # this is the registry username
# username: xxxxxx
# # this is the registry password
# password: xxxxxx
# tls:
# # path to the cert file used in the registry
# cert_file:
# # path to the key file used in the registry
# key_file:
# # path to the ca file used in the registry
# ca_file:
11 changes: 11 additions & 0 deletions tasks/build/containerd/registries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---

- name: Ensure containerd registries file exists
ansible.builtin.template:
src: registries.yaml.j2
dest: "{{ k3s_config_dir }}/registries.yaml"
mode: 0600
notify:
- reload systemd
- restart k3s
become: "{{ k3s_become_for_install_dir | ternary(true, false, k3s_become_for_all) }}"
8 changes: 8 additions & 0 deletions tasks/state-installed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@

- import_tasks: build/install-k3s.yml

- name: Ensure containerd installation tasks are run
block:
- include_tasks: build/containerd/registries.yml
when:
- k3s_registries is defined
anjia0532 marked this conversation as resolved.
Show resolved Hide resolved
- (k3s_runtime_config.docker is not defined or not k3s_runtime_config.docker)
- ('rootless' not in k3s_runtime_config or not k3s_runtime_config.rootless)

- include_tasks: validate/configuration/cluster-init.yml
when:
- k3s_control_delegate is defined
Expand Down
2 changes: 2 additions & 0 deletions templates/registries.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
{{ k3s_registries | to_nice_yaml }}
anjia0532 marked this conversation as resolved.
Show resolved Hide resolved