Skip to content

Commit

Permalink
Merge pull request #47 from lablabs/develop
Browse files Browse the repository at this point in the history
Add custom Containerd Registry
  • Loading branch information
MonolithProjects authored Feb 28, 2022
2 parents 75302c9 + d417bad commit ff1247d
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
max-parallel: 1
matrix:
config:
- image: "centos8"
- image: "rockylinux8"
tag: "latest"
- image: "ubuntu2004"
tag: "latest"
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The Role can install the RKE2 in 3 modes:

## Tested on

* CentOS 8
* Rocky Linux 8
* Ubuntu 20.04 LTS

## Role Variables
Expand Down Expand Up @@ -87,12 +87,17 @@ rke2_custom_manifests:
# Path to static pods deployed during the RKE2 installation
rke2_static_pods:

# Deploy RKE2 and set the custom containerd images registries
rke2_custom_registry: false
# Configure custom Containerd Registry
rke2_custom_registry_mirrors:
- name:
endpoint: {}

# Path to Container registry config file template
rke2_custom_registry_path: templates/registries.yaml.j2

# Path to RKE2 config file template
rke2_config: templates/config.yaml.j2

# Override default containerd snapshotter
rke2_snapshooter: overlayfs

Expand Down Expand Up @@ -133,6 +138,7 @@ rke2_agents_group_name: workers
# You could find the flags at https://docs.rke2.io/install/install_options/install_options/#configuring-linux-rke2-agent-nodes
# rke2_agent_options:
# - "option: value"

```

## Inventory file example
Expand Down
9 changes: 7 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,17 @@ rke2_custom_manifests:
# Path to static pods deployed during the RKE2 installation
rke2_static_pods:

# Deploy RKE2 and set the custom containerd images registries
rke2_custom_registry: false
# Configure custom Containerd Registry
rke2_custom_registry_mirrors:
- name:
endpoint: {}

# Path to Container registry config file template
rke2_custom_registry_path: templates/registries.yaml.j2

# Path to RKE2 config file template
rke2_config: templates/config.yaml.j2

# Override default containerd snapshotter
rke2_snapshooter: overlayfs

Expand Down
2 changes: 1 addition & 1 deletion molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ lint: |
ansible-lint --exclude molecule/
platforms:
- name: node1
image: "geerlingguy/docker-${image:-centos8}-ansible:${tag:-latest}"
image: "geerlingguy/docker-${image:-rockylinux8}-ansible:${tag:-latest}"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
Expand Down
14 changes: 10 additions & 4 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
- name: Install packages
ansible.builtin.package:
update_cache: true
name: "{{ item }}"
loop:
- wget
- curl
name:
- wget
- curl

- name: Install special packages for RockyLinux
ansible.builtin.package:
update_cache: true
name:
- iproute
when: ansible_distribution == "Rocky"
4 changes: 2 additions & 2 deletions tasks/first_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

- name: Copy kubeconfig
ansible.builtin.template:
src: templates/config.yaml.j2
src: "{{ rke2_config }}"
dest: /etc/rancher/rke2/config.yaml
owner: root
group: root
Expand All @@ -23,7 +23,7 @@
owner: root
group: root
mode: 0644
when: rke2_custom_registry | bool
when: rke2_custom_registry_mirrors.0.endpoint | length > 0

- name: Start RKE2 service on the first server
ansible.builtin.systemd:
Expand Down
4 changes: 2 additions & 2 deletions tasks/remaining_nodes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

- name: Copy RKE2 config
ansible.builtin.template:
src: templates/config.yaml.j2
src: "{{ rke2_config }}"
dest: /etc/rancher/rke2/config.yaml
owner: root
group: root
Expand All @@ -23,7 +23,7 @@
owner: root
group: root
mode: 0644
when: rke2_custom_registry | bool
when: rke2_custom_registry_mirrors.0.endpoint | length > 0

- name: Start RKE2 service on the rest of the nodes
ansible.builtin.systemd:
Expand Down
4 changes: 2 additions & 2 deletions tasks/standalone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

- name: Copy RKE2 config
ansible.builtin.template:
src: templates/config.yaml.j2
src: "{{ rke2_config }}"
dest: /etc/rancher/rke2/config.yaml
owner: root
group: root
Expand All @@ -23,7 +23,7 @@
owner: root
group: root
mode: 0644
when: rke2_custom_registry | bool
when: rke2_custom_registry_mirrors.0.endpoint | length > 0

- name: Start RKE2 service on the server node
ansible.builtin.systemd:
Expand Down
18 changes: 6 additions & 12 deletions templates/registries.yaml.j2
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
mirrors:
docker.io:
{% for mirror in rke2_custom_registry_mirrors %}
{{ mirror.name }}:
endpoint:
- "https://registry.example.com:5000"
configs:
"registry.example.com:5000":
auth:
username: xxxxxx # this is the registry username
password: xxxxxx # this is the registry password
tls:
cert_file: # path to the cert file used to authenticate to the registry
key_file: # path to the key file for the certificate used to authenticate to the registry
ca_file: # path to the ca file used to verify the registry's certificate
insecure_skip_verify: # may be set to true to skip verifying the registry's certificate
{% for endpoint in mirror.endpoint %}
- "{{ endpoint }}"
{% endfor %}
{% endfor %}

0 comments on commit ff1247d

Please sign in to comment.