Skip to content

Commit

Permalink
fix: Configure correct apt sources (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
bissquit authored Apr 9, 2024
1 parent e4662db commit 9660432
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
pull_request_target:
types:
- opened
- reopened
- edited
- synchronize

jobs:
pr-title:
Expand Down
37 changes: 18 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,24 @@ Role Variables

All variables are defined as defaults in [defaults/main.yml](defaults/main.yml) and may be overrided.

| Name | Default value | Description |
|--------------------------------------------|----------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `k8s_cluster_kubelet_version` | 1.26.0-00 | kubelet version |
| `k8s_cluster_kubeadm_version` | 1.26.0-00 | kubeadm version |
| `k8s_cluster_kubectl_version` | 1.26.0-00 | kubectl version |
| `k8s_cluster_apt_key_url` | https://packages.cloud.google.com/apt/doc/apt-key.gpg | Apt key url |
| `k8s_cluster_apt_repository` | deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main | Apt repository |
| `k8s_cluster_kubernetes_version` | 1.26.0 | Kubernetes version |
| `k8s_cluster_kubelet_config_root_dir` | /etc/kubernetes | Default kubelet configuration directory |
| `k8s_cluster_node_type` | worker | Default node type. If you need to init or join master, you should set this variable to 'master' |
| `k8s_cluster_node_name` | inventory_hostname | Name of k8s node |
| `k8s_cluster_initial_master` | false | This variable identifies initial master node to initialize cluster. It should be assigned to the only node with 'true' value |
| `k8s_cluster_init_configuration` | See [defaults/main.yml](defaults/main.yml) | Represents `kind: InitConfiguration` of the cluster in pure yaml format |
| `k8s_cluster_cluster_configuration` | See [defaults/main.yml](defaults/main.yml) | Represents `kind: ClusterConfiguration` of the cluster in pure yaml format |
| `k8s_cluster_kubelet_configuration` | See [defaults/main.yml](defaults/main.yml) | Represents `kind: KubeletConfiguration` in pure yaml format |
| `k8s_cluster_kubeproxy_configuration` | "" | Represents `kind: KubeproxyConfiguration` in pure yaml format |
| `k8s_cluster_join_configuration` | See [defaults/main.yml](defaults/main.yml) | Represents `kind: JoinConfiguration` of the cluster in pure yaml format |
| `k8s_cluster_flannel_apply` | https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml | Default Flannel manifest. Read more about [Flannel](https://github.com/flannel-io/flannel) |
| `k8s_cluster_custom_networking_tasks_path` | "" | Path to file with a set of tasks to configure networking. It could be a set of tasks or even `include_role` statement. It will run only once during cluster initialization |
| Name | Default value | Description |
|--------------------------------------------|----------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `k8s_cluster_kube_version` | 1.28.8-1.1 | `kubelet`, `kubeadm` and `kubectl` versions |
| `k8s_cluster_apt_key_url` | https://packages.cloud.google.com/apt/doc/apt-key.gpg | Apt key url |
| `k8s_cluster_apt_key_file` | /usr/share/keyrings/kubernetes-archive-keyring.gpg | Apt key file |
| `k8s_cluster_apt_repository` | deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main | Apt repository |
| `k8s_cluster_kubernetes_version` | 1.28.8 | Kubernetes version |
| `k8s_cluster_kubelet_config_root_dir` | /etc/kubernetes | Default kubelet configuration directory |
| `k8s_cluster_node_type` | worker | Default node type. If you need to init or join master, you should set this variable to 'master' |
| `k8s_cluster_node_name` | inventory_hostname | Name of k8s node |
| `k8s_cluster_initial_master` | false | This variable identifies initial master node to initialize cluster. It should be assigned to the only node with 'true' value |
| `k8s_cluster_init_configuration` | See [defaults/main.yml](defaults/main.yml) | Represents `kind: InitConfiguration` of the cluster in pure yaml format |
| `k8s_cluster_cluster_configuration` | See [defaults/main.yml](defaults/main.yml) | Represents `kind: ClusterConfiguration` of the cluster in pure yaml format |
| `k8s_cluster_kubelet_configuration` | See [defaults/main.yml](defaults/main.yml) | Represents `kind: KubeletConfiguration` in pure yaml format |
| `k8s_cluster_kubeproxy_configuration` | "" | Represents `kind: KubeproxyConfiguration` in pure yaml format |
| `k8s_cluster_join_configuration` | See [defaults/main.yml](defaults/main.yml) | Represents `kind: JoinConfiguration` of the cluster in pure yaml format |
| `k8s_cluster_flannel_apply` | https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml | Default Flannel manifest. Read more about [Flannel](https://github.com/flannel-io/flannel) |
| `k8s_cluster_custom_networking_tasks_path` | "" | Path to file with a set of tasks to configure networking. It could be a set of tasks or even `include_role` statement. It will run only once during cluster initialization |

\* except `apiVersion` and `kind` fields

Expand Down
18 changes: 12 additions & 6 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
---

k8s_cluster_kubelet_version: '1.26.0-00'
k8s_cluster_kubeadm_version: '1.26.0-00'
k8s_cluster_kubectl_version: '1.26.0-00'
# common version for kubernetes related applications - kubelet, kubeadm, kubectl
k8s_cluster_kube_version: 1.28.8-1.1

k8s_cluster_apt_key_url: 'https://packages.cloud.google.com/apt/doc/apt-key.gpg'
k8s_cluster_apt_repository: 'deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main'
# read more at the following sources:
# https://kubernetes.io/blog/2023/08/31/legacy-package-repository-deprecation/
# https://kubernetes.io/blog/2023/08/15/pkgs-k8s-io-introduction/
#
# 'k8s_cluster_apt_kubernetes_version' will be calculated during role execution using set_fact
k8s_cluster_apt_key_url: "https://pkgs.k8s.io/core:/stable:/{{ k8s_cluster_apt_kubernetes_version }}/deb/Release.key"
k8s_cluster_apt_key_file: "/usr/share/keyrings/kubernetes-archive-keyring.gpg"
k8s_cluster_apt_repository: 'deb [signed-by={{ k8s_cluster_apt_key_file }}] https://pkgs.k8s.io/core:/stable:/{{ k8s_cluster_apt_kubernetes_version }}/deb/ /'

k8s_cluster_kubernetes_version: 1.26.0
# without leading 'v', numbers and dots only
k8s_cluster_kubernetes_version: 1.28.8
k8s_cluster_kubelet_config_root_dir: '/etc/kubernetes'

k8s_cluster_node_type: worker
Expand Down
1 change: 0 additions & 1 deletion handlers/main.yml

This file was deleted.

4 changes: 3 additions & 1 deletion molecule/default_ext-etcd-sec/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ provisioner:
host_vars:
k8s-control-plane-01:
k8s_cluster_initial_master: true
k8s_cluster_kubernetes_version: 1.26.0
k8s_cluster_kubernetes_version: 1.28.8
k8s_cluster_cluster_configuration:
etcd:
external:
Expand Down Expand Up @@ -89,6 +89,8 @@ provisioner:
all:
# cloudlabsinfra.etcd_cluster_certificates role related variables
etcd_cert_dir: /etc/ssl/private
# k8s_cluster role related variables
k8s_cluster_kube_version: 1.28.8-1.1
control_plane:
k8s_cluster_node_type: "master"
etcd_cert_matrix:
Expand Down
4 changes: 3 additions & 1 deletion molecule/end-to-end/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ provisioner:
k8s-control-plane-01:
# cloudlabsinfra.k8s_cluster role related variables
k8s_cluster_initial_master: true
k8s_cluster_kubernetes_version: 1.26.0
# we can't use default cluster configuration here because it doesn't have 'etcd' section
k8s_cluster_cluster_configuration:
etcd:
Expand Down Expand Up @@ -149,6 +148,9 @@ provisioner:
all:
# required for control-plane nodes and etcd as well
etcd_frontend_name: "etcd.cloudlabsinfra.local"
# k8s_cluster role related variables
k8s_cluster_kube_version: 1.28.8-1.1
k8s_cluster_kubernetes_version: 1.28.8
k8s_cluster_control_plane_endpoint: "control-plane.cloudlabsinfra.local"
control_plane:
# default value of variable below is 'worker'
Expand Down
17 changes: 12 additions & 5 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,31 @@
state: present
update_cache: yes

- name: Set proper version for apt repo
ansible.builtin.set_fact:
# input: 1.27.1 or 1.27.13 or v1.27.13
# output: v1.27
# first slash escapes second slash
k8s_cluster_apt_kubernetes_version: "{{ k8s_cluster_kubernetes_version | regex_replace('^v?(\\d\\.\\d\\d)\\.\\d*$', 'v\\1') }}"

- name: Add Kubernetes apt key
ansible.builtin.apt_key:
url: "{{ k8s_cluster_apt_key_url }}"
keyring: /usr/share/keyrings/kubernetes-archive-keyring.gpg
keyring: "{{ k8s_cluster_apt_key_file }}"

- name: Add Kubernetes apt repository
ansible.builtin.apt_repository:
repo: "{{ k8s_cluster_apt_repository }}"
state: present
# filename: kubernetes
#filename: kubernetes
update_cache: true

- name: Install Kubernetes components
ansible.builtin.apt:
name:
- kubelet={{ k8s_cluster_kubelet_version }}
- kubeadm={{ k8s_cluster_kubeadm_version }}
- kubectl={{ k8s_cluster_kubectl_version }}
- kubelet={{ k8s_cluster_kube_version }}
- kubeadm={{ k8s_cluster_kube_version }}
- kubectl={{ k8s_cluster_kube_version }}
allow_unauthenticated: yes
update_cache: yes

Expand Down
2 changes: 0 additions & 2 deletions vars/main.yml

This file was deleted.

0 comments on commit 9660432

Please sign in to comment.