├── .gitignore
├── .ansible-lint
├── molecule
└── default
│ ├── collections.yml
│ ├── host_vars
│ ├── test-assets.yml
│ ├── test-controller3.yml
│ ├── test-worker2.yml
│ ├── test-controller1.yml
│ ├── test-controller2.yml
│ └── test-worker1.yml
│ ├── tasks
│ └── taint_controller_nodes.yml
│ ├── converge.yml
│ ├── verify.yml
│ ├── molecule.yml
│ ├── prepare.yml
│ └── group_vars
│ └── all.yml
├── templates
├── etc
│ ├── kubernetes
│ │ └── controller
│ │ │ └── kube-scheduler
│ │ │ └── kube-scheduler.yaml.j2
│ └── systemd
│ │ └── system
│ │ ├── kube-apiserver.service.j2
│ │ ├── kube-scheduler.service.j2
│ │ └── kube-controller-manager.service.j2
└── rbac
│ ├── kube-apiserver-to-kubelet_cluster_role_binding.yaml.j2
│ └── kube-apiserver-to-kubelet_cluster_role.yaml.j2
├── .yamllint
├── meta
└── main.yml
├── handlers
└── main.yml
├── vars
└── main.yml
├── .github
└── workflows
│ └── release.yml
├── tasks
├── authconfig
│ ├── kube-scheduler.yml
│ ├── kube-controller-manager.yml
│ └── kube-admin-user.yml
└── main.yml
├── defaults
└── main.yml
├── README.md
├── CHANGELOG.md
└── LICENSE
/.gitignore:
--------------------------------------------------------------------------------
1 | *.swp
2 | *.retry
3 | .ansible
4 | .vscode
5 |
--------------------------------------------------------------------------------
/.ansible-lint:
--------------------------------------------------------------------------------
1 | ---
2 | skip_list:
3 | - role-name
4 | - command-instead-of-shell
5 |
--------------------------------------------------------------------------------
/molecule/default/collections.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # Copyright (C) 2023 Robert Wimmer
3 | # SPDX-License-Identifier: GPL-3.0-or-later
4 |
5 | collections:
6 | - ansible.posix
7 | - kubernetes.core
8 |
--------------------------------------------------------------------------------
/molecule/default/host_vars/test-assets.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # Copyright (C) 2023 Robert Wimmer
3 | # SPDX-License-Identifier: GPL-3.0-or-later
4 |
5 | wireguard_address: "10.10.10.5/24"
6 | wireguard_port: 51820
7 | wireguard_persistent_keepalive: "30"
8 | wireguard_endpoint: "172.16.10.5"
9 |
--------------------------------------------------------------------------------
/molecule/default/host_vars/test-controller3.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # Copyright (C) 2023 Robert Wimmer
3 | # SPDX-License-Identifier: GPL-3.0-or-later
4 |
5 | wireguard_address: "10.10.10.30/24"
6 | wireguard_port: 51820
7 | wireguard_persistent_keepalive: "30"
8 | wireguard_endpoint: "172.16.10.30"
9 |
--------------------------------------------------------------------------------
/molecule/default/host_vars/test-worker2.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # Copyright (C) 2023 Robert Wimmer
3 | # SPDX-License-Identifier: GPL-3.0-or-later
4 |
5 | wireguard_address: "10.10.10.110/24"
6 | wireguard_port: 51820
7 | wireguard_persistent_keepalive: "30"
8 | wireguard_endpoint: "172.16.10.110"
9 |
--------------------------------------------------------------------------------
/templates/etc/kubernetes/controller/kube-scheduler/kube-scheduler.yaml.j2:
--------------------------------------------------------------------------------
1 | #jinja2: trim_blocks:False
2 | apiVersion: kubescheduler.config.k8s.io/v1
3 | kind: KubeSchedulerConfiguration
4 | clientConnection:
5 | kubeconfig: "{{ k8s_scheduler_conf_dir }}/kubeconfig"
6 | leaderElection:
7 | leaderElect: true
8 |
--------------------------------------------------------------------------------
/.yamllint:
--------------------------------------------------------------------------------
1 | ---
2 | extends: default
3 |
4 | rules:
5 | line-length:
6 | max: 300
7 | level: warning
8 |
9 | comments-indentation: disable
10 | comments:
11 | min-spaces-from-content: 1
12 | braces:
13 | min-spaces-inside: 0
14 | max-spaces-inside: 1
15 | octal-values:
16 | forbid-implicit-octal: true
17 | forbid-explicit-octal: true
18 |
--------------------------------------------------------------------------------
/molecule/default/host_vars/test-controller1.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # Copyright (C) 2023 Robert Wimmer
3 | # SPDX-License-Identifier: GPL-3.0-or-later
4 |
5 | wireguard_address: "10.10.10.10/24"
6 | wireguard_port: 51820
7 | wireguard_persistent_keepalive: "30"
8 | wireguard_endpoint: "172.16.10.10"
9 |
10 | k8s_ctl_api_endpoint_host: "127.0.0.1"
11 | k8s_ctl_api_endpoint_port: "16443"
12 |
--------------------------------------------------------------------------------
/molecule/default/host_vars/test-controller2.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # Copyright (C) 2023 Robert Wimmer
3 | # SPDX-License-Identifier: GPL-3.0-or-later
4 |
5 | wireguard_address: "10.10.10.20/24"
6 | wireguard_port: 51820
7 | wireguard_persistent_keepalive: "30"
8 | wireguard_endpoint: "172.16.10.20"
9 |
10 | k8s_ctl_api_endpoint_host: "127.0.0.1"
11 | k8s_ctl_api_endpoint_port: "16443"
12 |
--------------------------------------------------------------------------------
/molecule/default/host_vars/test-worker1.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # Copyright (C) 2023 Robert Wimmer
3 | # SPDX-License-Identifier: GPL-3.0-or-later
4 |
5 | wireguard_address: "10.10.10.100/24"
6 | wireguard_port: 51820
7 | wireguard_persistent_keepalive: "30"
8 | wireguard_endpoint: "172.16.10.100"
9 |
10 | ha_proxy_frontend_bind_address: "127.0.0.1"
11 | ha_proxy_frontend_port: "16443"
12 |
13 | k8s_ctl_api_endpoint_host: "127.0.0.1"
14 |
--------------------------------------------------------------------------------
/templates/rbac/kube-apiserver-to-kubelet_cluster_role_binding.yaml.j2:
--------------------------------------------------------------------------------
1 | ---
2 | apiVersion: rbac.authorization.k8s.io/v1
3 | kind: ClusterRoleBinding
4 | metadata:
5 | name: system:kube-apiserver
6 | namespace: ""
7 | roleRef:
8 | apiGroup: rbac.authorization.k8s.io
9 | kind: ClusterRole
10 | name: system:kube-apiserver-to-kubelet
11 | subjects:
12 | - apiGroup: rbac.authorization.k8s.io
13 | kind: User
14 | name: {{ k8s_apiserver_csr_cn }}
15 |
--------------------------------------------------------------------------------
/meta/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | galaxy_info:
3 | author: Robert Wimmer
4 | description: Installs the Kubernetes API server, scheduler and controller manager.
5 | license: GPLv3
6 | min_ansible_version: "2.15"
7 | role_name: kubernetes_controller
8 | namespace: githubixx
9 | platforms:
10 | - name: Ubuntu
11 | versions:
12 | - "jammy"
13 | - "noble"
14 | galaxy_tags:
15 | - kubernetes
16 | - scheduler
17 | - api
18 | - controller
19 | - ha
20 |
--------------------------------------------------------------------------------
/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Reload systemd
3 | ansible.builtin.systemd:
4 | daemon_reload: true
5 |
6 | - name: Restart kube-apiserver
7 | ansible.builtin.service:
8 | name: kube-apiserver
9 | state: restarted
10 |
11 | - name: Restart kube-controller-manager
12 | ansible.builtin.service:
13 | name: kube-controller-manager
14 | state: restarted
15 |
16 | - name: Restart kube-scheduler
17 | ansible.builtin.service:
18 | name: kube-scheduler
19 | state: restarted
20 |
--------------------------------------------------------------------------------
/templates/rbac/kube-apiserver-to-kubelet_cluster_role.yaml.j2:
--------------------------------------------------------------------------------
1 | ---
2 | apiVersion: rbac.authorization.k8s.io/v1
3 | kind: ClusterRole
4 | metadata:
5 | annotations:
6 | rbac.authorization.kubernetes.io/autoupdate: "true"
7 | labels:
8 | kubernetes.io/bootstrapping: rbac-defaults
9 | name: system:kube-apiserver-to-kubelet
10 | rules:
11 | - apiGroups:
12 | - ""
13 | resources:
14 | - nodes/proxy
15 | - nodes/stats
16 | - nodes/log
17 | - nodes/spec
18 | - nodes/metrics
19 | verbs:
20 | - "*"
21 |
--------------------------------------------------------------------------------
/molecule/default/tasks/taint_controller_nodes.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # Copyright (C) 2023 Robert Wimmer
3 | # SPDX-License-Identifier: GPL-3.0-or-later
4 |
5 | - name: Taint Kubernetes control plane nodes
6 | kubernetes.core.k8s_taint:
7 | state: present
8 | name: "{{ k8s_controller_node }}"
9 | taints:
10 | - effect: NoExecute
11 | key: "node-role.kubernetes.io/control-plane"
12 | - effect: NoSchedule
13 | key: "node-role.kubernetes.io/control-plane"
14 | loop: "{{ groups['k8s_controller'] }}"
15 | loop_control:
16 | loop_var: k8s_controller_node
17 |
--------------------------------------------------------------------------------
/templates/etc/systemd/system/kube-apiserver.service.j2:
--------------------------------------------------------------------------------
1 | #jinja2: trim_blocks:False
2 | [Unit]
3 | Description=Kubernetes API Server
4 | Documentation=https://github.com/GoogleCloudPlatform/kubernetes
5 | Wants=network-online.target
6 | After=network-online.target
7 |
8 | [Service]
9 | ExecStart={{ k8s_ctl_bin_dir }}/kube-apiserver \
10 | {%- for setting in k8s_apiserver_settings|sort %}
11 | --{{ setting }}={{ k8s_apiserver_settings[setting] }} {% if not loop.last %}\{% endif %}
12 | {%- endfor %}
13 | {%- for setting in k8s_ctl_service_options %}
14 | {{ setting }}
15 | {%- endfor %}
16 |
17 | [Install]
18 | WantedBy=multi-user.target
19 |
--------------------------------------------------------------------------------
/molecule/default/converge.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # Copyright (C) 2023 Robert Wimmer
3 | # SPDX-License-Identifier: GPL-3.0-or-later
4 |
5 | - name: Setup Kubernetes controller
6 | hosts: k8s_controller
7 | become: true
8 | gather_facts: true
9 | tasks:
10 | - name: Include kubernetes_controller role
11 | ansible.builtin.include_role:
12 | name: githubixx.kubernetes_controller
13 |
14 | # - name: Taint Kubernetes control plane nodes
15 | # hosts: k8s_assets
16 | # become: true
17 | # gather_facts: true
18 | # tasks:
19 | # - name: Control plane nodes should only run critical pods
20 | # ansible.builtin.include_tasks:
21 | # file: tasks/taint_controller_nodes.yml
22 |
--------------------------------------------------------------------------------
/templates/etc/systemd/system/kube-scheduler.service.j2:
--------------------------------------------------------------------------------
1 | #jinja2: trim_blocks:False
2 | [Unit]
3 | Description=Kubernetes Scheduler
4 | Documentation=https://github.com/GoogleCloudPlatform/kubernetes
5 | Wants=network-online.target
6 | Wants=kube-apiserver.service
7 | After=network-online.target
8 | After=kube-apiserver.service
9 |
10 | [Service]
11 | ExecStartPre=/usr/bin/timeout 30 sh -c 'while ! ss -H -t -l -n sport = :{{ k8s_ctl_api_endpoint_port }} | grep -q "^LISTEN.*:{{ k8s_ctl_api_endpoint_port }}"; do sleep 1; done'
12 | ExecStart={{ k8s_ctl_bin_dir }}/kube-scheduler \
13 | {%- for setting in k8s_scheduler_settings | sort %}
14 | --{{ setting }}={{ k8s_scheduler_settings[setting] }} {% if not loop.last %}\{% endif %}
15 | {%- endfor %}
16 | {%- for setting in k8s_ctl_service_options %}
17 | {{ setting }}
18 | {%- endfor %}
19 |
20 | [Install]
21 | WantedBy=multi-user.target
22 |
--------------------------------------------------------------------------------
/templates/etc/systemd/system/kube-controller-manager.service.j2:
--------------------------------------------------------------------------------
1 | #jinja2: trim_blocks:False
2 | [Unit]
3 | Description=Kubernetes Controller Manager
4 | Documentation=https://github.com/GoogleCloudPlatform/kubernetes
5 | Wants=network-online.target
6 | Wants=kube-apiserver.service
7 | After=network-online.target
8 | After=kube-apiserver.service
9 |
10 | [Service]
11 | ExecStartPre=/usr/bin/timeout 30 sh -c 'while ! ss -H -t -l -n sport = :{{ k8s_ctl_api_endpoint_port }} | grep -q "^LISTEN.*:{{ k8s_ctl_api_endpoint_port }}"; do sleep 1; done'
12 | ExecStart={{ k8s_ctl_bin_dir }}/kube-controller-manager \
13 | {%- for setting in k8s_controller_manager_settings|sort %}
14 | --{{ setting }}={{ k8s_controller_manager_settings[setting] }} {% if not loop.last %}\{% endif %}
15 | {%- endfor %}
16 | {%- for setting in k8s_ctl_service_options %}
17 | {{ setting }}
18 | {%- endfor %}
19 |
20 | [Install]
21 | WantedBy=multi-user.target
22 |
--------------------------------------------------------------------------------
/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # Kubernetes control plane binaries to download.
3 | k8s_ctl_binaries:
4 | - kube-apiserver
5 | - kube-controller-manager
6 | - kube-scheduler
7 | - kubectl
8 |
9 | # Kubernetes certificates for:
10 | # kube-(apiserver|controller-manager|controller-manager-sa|scheduler)
11 | k8s_ctl_certificates:
12 | - ca-k8s-apiserver.pem
13 | - ca-k8s-apiserver-key.pem
14 | - cert-k8s-apiserver.pem
15 | - cert-k8s-apiserver-key.pem
16 | - cert-k8s-controller-manager-sa.pem
17 | - cert-k8s-controller-manager-sa-key.pem
18 | - cert-k8s-scheduler.pem
19 | - cert-k8s-scheduler-key.pem
20 | - cert-k8s-controller-manager.pem
21 | - cert-k8s-controller-manager-key.pem
22 |
23 | # The "etcd" certificates needed for the control plane components to be able
24 | # to connect to the "etcd" cluster.
25 | k8s_ctl_etcd_certificates:
26 | - ca-etcd.pem
27 | - ca-etcd-key.pem
28 | - cert-k8s-apiserver-etcd.pem
29 | - cert-k8s-apiserver-etcd-key.pem
30 |
--------------------------------------------------------------------------------
/molecule/default/verify.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # Copyright (C) 2023 Robert Wimmer
3 | # SPDX-License-Identifier: GPL-3.0-or-later
4 |
5 | - name: Verify setup
6 | hosts: test-assets
7 | tasks:
8 | - name: Fetch namespaces information
9 | kubernetes.core.k8s_info:
10 | api_version: v1
11 | kind: namespace
12 | kubeconfig: "{{ k8s_admin_conf_dir }}/admin.kubeconfig"
13 | register: k8s__namespaces_info
14 |
15 | - name: Print namespaces
16 | ansible.builtin.debug:
17 | var: "{{ k8s__namespaces_info | community.general.json_query(json_query) }}"
18 | vars:
19 | json_query: "length(resources)"
20 | when: ansible_verbosity > 1
21 |
22 | - name: Register namespaces count
23 | ansible.builtin.set_fact:
24 | k8s__namespaces_count: "{{ k8s__namespaces_info | community.general.json_query(json_query) }}"
25 | vars:
26 | json_query: "length(resources)"
27 |
28 | - name: There should be four namespaces
29 | ansible.builtin.assert:
30 | that:
31 | - k8s__namespaces_count|int == 4
32 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # This workflow requires a GALAXY_API_KEY secret present in the GitHub
3 | # repository or organization.
4 | #
5 | # See: https://github.com/marketplace/actions/publish-ansible-role-to-galaxy
6 | # See: https://github.com/ansible/galaxy/issues/46
7 |
8 | name: Release
9 | on:
10 | push:
11 | tags:
12 | - '*'
13 |
14 | defaults:
15 | run:
16 | working-directory: 'githubixx.kubernetes_controller'
17 |
18 | jobs:
19 | release:
20 | name: Release
21 | runs-on: ubuntu-latest
22 | steps:
23 | - name: Check out the codebase.
24 | uses: actions/checkout@v2
25 | with:
26 | path: 'githubixx.kubernetes_controller'
27 |
28 | - name: Set up Python 3.
29 | uses: actions/setup-python@v2
30 | with:
31 | python-version: '3.x'
32 |
33 | - name: Install Ansible.
34 | run: pip3 install ansible-core
35 |
36 | - name: Trigger a new import on Galaxy.
37 | run: >-
38 | ansible-galaxy role import --token ${{ secrets.GALAXY_API_KEY }} -vvvvvvvv --role-name=$(echo ${{ github.repository }} | cut -d/ -f2 | sed 's/ansible-role-//' | sed 's/-/_/') $(echo ${{ github.repository }} | cut -d/ -f1) $(echo ${{ github.repository }} | cut -d/ -f2)
39 |
--------------------------------------------------------------------------------
/molecule/default/molecule.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # Copyright (C) 2023 Robert Wimmer
3 | # SPDX-License-Identifier: GPL-3.0-or-later
4 |
5 | dependency:
6 | name: galaxy
7 |
8 | driver:
9 | name: vagrant
10 | provider:
11 | name: libvirt
12 | type: libvirt
13 |
14 | platforms:
15 | - name: test-assets
16 | box: alvistack/ubuntu-24.04
17 | memory: 2048
18 | cpus: 2
19 | groups:
20 | - vpn
21 | - k8s_assets
22 | - k8s
23 | interfaces:
24 | - auto_config: true
25 | network_name: private_network
26 | type: static
27 | ip: 172.16.10.5
28 | - name: test-controller1
29 | box: alvistack/ubuntu-22.04
30 | memory: 2048
31 | cpus: 2
32 | groups:
33 | - vpn
34 | - ubuntu22
35 | - k8s_controller
36 | - k8s_worker
37 | - k8s_etcd
38 | - k8s
39 | interfaces:
40 | - auto_config: true
41 | network_name: private_network
42 | type: static
43 | ip: 172.16.10.10
44 | - name: test-controller2
45 | box: alvistack/ubuntu-22.04
46 | memory: 2048
47 | cpus: 2
48 | groups:
49 | - vpn
50 | - ubuntu22
51 | - k8s_controller
52 | - k8s_worker
53 | - k8s_etcd
54 | - k8s
55 | interfaces:
56 | - auto_config: true
57 | network_name: private_network
58 | type: static
59 | ip: 172.16.10.20
60 | - name: test-controller3
61 | box: alvistack/ubuntu-24.04
62 | memory: 2048
63 | cpus: 2
64 | groups:
65 | - vpn
66 | - ubuntu24
67 | - k8s_controller
68 | - k8s_worker
69 | - k8s_etcd
70 | - k8s
71 | interfaces:
72 | - auto_config: true
73 | network_name: private_network
74 | type: static
75 | ip: 172.16.10.30
76 | - name: test-worker1
77 | box: alvistack/ubuntu-22.04
78 | memory: 2048
79 | cpus: 2
80 | groups:
81 | - vpn
82 | - ubuntu22
83 | - k8s_worker
84 | - k8s
85 | interfaces:
86 | - auto_config: true
87 | network_name: private_network
88 | type: static
89 | ip: 172.16.10.100
90 | - name: test-worker2
91 | box: alvistack/ubuntu-24.04
92 | memory: 2048
93 | cpus: 2
94 | groups:
95 | - vpn
96 | - ubuntu24
97 | - k8s_worker
98 | - k8s
99 | interfaces:
100 | - auto_config: true
101 | network_name: private_network
102 | type: static
103 | ip: 172.16.10.110
104 |
105 | provisioner:
106 | name: ansible
107 | connection_options:
108 | ansible_ssh_user: vagrant
109 | ansible_become: true
110 | log: true
111 | lint: yamllint . && flake8
112 |
113 | scenario:
114 | name: default
115 | test_sequence:
116 | - prepare
117 | - converge
118 |
119 | verifier:
120 | name: ansible
121 | enabled: true
122 |
--------------------------------------------------------------------------------
/molecule/default/prepare.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # Copyright (C) 2023 Robert Wimmer
3 | # SPDX-License-Identifier: GPL-3.0-or-later
4 |
5 | - name: Update cache
6 | hosts: k8s
7 | remote_user: vagrant
8 | become: true
9 | gather_facts: true
10 | tasks:
11 | - name: Update APT package cache
12 | ansible.builtin.apt:
13 | update_cache: true
14 | cache_valid_time: 3600
15 |
16 | - name: Harden hosts
17 | hosts: all
18 | remote_user: vagrant
19 | become: true
20 | gather_facts: true
21 | tasks:
22 | - name: Setup harden_linux role
23 | ansible.builtin.include_role:
24 | name: githubixx.harden_linux
25 |
26 | - name: Setup Wireguard VPN
27 | hosts: vpn
28 | remote_user: vagrant
29 | become: true
30 | gather_facts: true
31 | tasks:
32 | - name: Setup wireguard role
33 | ansible.builtin.include_role:
34 | name: githubixx.ansible_role_wireguard
35 |
36 | - name: Setup cfssl
37 | hosts: k8s_assets
38 | become: true
39 | gather_facts: false
40 | tasks:
41 | - name: Install cfssl
42 | ansible.builtin.include_role:
43 | name: githubixx.cfssl
44 |
45 | - name: Setup Kubernetes certificates
46 | hosts: k8s_assets
47 | gather_facts: false
48 | tasks:
49 | - name: Generate etcd and K8s TLS certificates
50 | ansible.builtin.include_role:
51 | name: githubixx.kubernetes_ca
52 |
53 | - name: Copy certificate files from assets to local host
54 | ansible.posix.synchronize:
55 | mode: pull
56 | src: "{{ k8s_ctl_ca_conf_directory }}"
57 | dest: "/tmp"
58 |
59 | - name: Setup etcd
60 | hosts: k8s_etcd
61 | remote_user: vagrant
62 | become: true
63 | gather_facts: true
64 | tasks:
65 | - name: Include etcd role
66 | ansible.builtin.include_role:
67 | name: githubixx.etcd
68 |
69 | - name: Setup Kubernetes client tooling
70 | hosts: k8s_assets
71 | become: true
72 | gather_facts: true
73 | tasks:
74 | - name: Install kubectl
75 | ansible.builtin.include_role:
76 | name: githubixx.kubectl
77 |
78 | - name: Install support packages
79 | ansible.builtin.package:
80 | name: "{{ packages }}"
81 | state: present
82 | vars:
83 | packages:
84 | - conntrack
85 | - python3-pip
86 |
87 | - name: Install kubernetes Python package
88 | ansible.builtin.package:
89 | name: python3-kubernetes
90 | state: present
91 |
92 | - name: Setup HAProxy
93 | hosts: ubuntu22
94 | remote_user: vagrant
95 | become: true
96 | gather_facts: true
97 | tasks:
98 | - name: Setup haproxy role
99 | ansible.builtin.include_role:
100 | name: githubixx.haproxy
101 |
102 | - name: Install CNI plugins and runc
103 | hosts: k8s
104 | remote_user: vagrant
105 | become: true
106 | gather_facts: true
107 | tasks:
108 | - name: Include runc role
109 | ansible.builtin.include_role:
110 | name: githubixx.runc
111 |
112 | - name: Include CNI role
113 | ansible.builtin.include_role:
114 | name: githubixx.cni
115 |
--------------------------------------------------------------------------------
/tasks/authconfig/kube-scheduler.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Register checksum of kube-scheduler original kubeconfig
3 | ansible.builtin.stat:
4 | path: "{{ k8s_scheduler_conf_dir }}/kubeconfig"
5 | register: k8s_ctl__scheduler_kubeconfig_orig_stat
6 |
7 | - name: Generate kubeconfig for kube-scheduler (set-cluster)
8 | ansible.builtin.shell: >
9 | set -o errexit; \
10 | kubectl config set-cluster {{ k8s_config_cluster_name }} \
11 | --certificate-authority={{ k8s_ctl_pki_dir }}/ca-k8s-apiserver.pem \
12 | --embed-certs=true \
13 | --server=https://{{ k8s_ctl_api_endpoint_host }}:{{ k8s_ctl_api_endpoint_port }} \
14 | --kubeconfig={{ k8s_scheduler_conf_dir }}/kubeconfig
15 | args:
16 | executable: /bin/bash
17 | register: k8s_ctl__set_cluster_out
18 | changed_when: false
19 | failed_when: k8s_ctl__set_cluster_out.rc != 0
20 |
21 | - name: Generate kubeconfig for kube-scheduler (set-cluster) - DEBUG OUTPUT
22 | ansible.builtin.debug:
23 | msg: "COMMAND:{{ k8s_ctl__set_cluster_out.cmd }} | OUTPUT: {{ k8s_ctl__set_cluster_out.stdout }}"
24 | verbosity: 2
25 |
26 | - name: Generate kubeconfig for kube-scheduler (set-credentials)
27 | ansible.builtin.shell: >
28 | set -o errexit; \
29 | kubectl config set-credentials system:kube-scheduler \
30 | --client-certificate={{ k8s_ctl_pki_dir }}/cert-k8s-scheduler.pem \
31 | --client-key={{ k8s_ctl_pki_dir }}/cert-k8s-scheduler-key.pem \
32 | --embed-certs=true \
33 | --kubeconfig={{ k8s_scheduler_conf_dir }}/kubeconfig
34 | args:
35 | executable: /bin/bash
36 | register: k8s_ctl__set_credentials_out
37 | changed_when: false
38 | failed_when: k8s_ctl__set_credentials_out.rc != 0
39 |
40 | - name: Generate kubeconfig for kube-scheduler (set-credentials) - DEBUG OUTPUT
41 | ansible.builtin.debug:
42 | msg: "COMMAND:{{ k8s_ctl__set_credentials_out.cmd }} | OUTPUT: {{ k8s_ctl__set_credentials_out.stdout }}"
43 | verbosity: 2
44 |
45 | - name: Generate kubeconfig for kube-scheduler (set-context)
46 | ansible.builtin.shell: >
47 | set -o errexit; \
48 | kubectl config set-context default \
49 | --cluster={{ k8s_config_cluster_name }} \
50 | --user=system:kube-scheduler \
51 | --kubeconfig={{ k8s_scheduler_conf_dir }}/kubeconfig
52 | args:
53 | executable: /bin/bash
54 | register: k8s_ctl__set_context_out
55 | changed_when: false
56 | failed_when: k8s_ctl__set_context_out.rc != 0
57 |
58 | - name: Generate kubeconfig for kube-scheduler (set-context) - DEBUG OUTPUT
59 | ansible.builtin.debug:
60 | msg: "COMMAND:{{ k8s_ctl__set_context_out.cmd }} | OUTPUT: {{ k8s_ctl__set_context_out.stdout }}"
61 | verbosity: 2
62 |
63 | - name: Generate kubeconfig for kube-scheduler (use-context)
64 | ansible.builtin.shell: >
65 | set -o errexit; \
66 | kubectl config use-context default \
67 | --kubeconfig={{ k8s_scheduler_conf_dir }}/kubeconfig
68 | args:
69 | executable: /bin/bash
70 | register: k8s_ctl__use_context_out
71 | changed_when: false
72 | failed_when: k8s_ctl__use_context_out.rc != 0
73 |
74 | - name: Generate kubeconfig for kube-scheduler (use-context) - DEBUG OUTPUT
75 | ansible.builtin.debug:
76 | msg: "COMMAND:{{ k8s_ctl__use_context_out.cmd }} | OUTPUT: {{ k8s_ctl__use_context_out.stdout }}"
77 | verbosity: 2
78 |
79 | - name: Set file permissions
80 | ansible.builtin.file:
81 | path: "{{ k8s_scheduler_conf_dir }}/kubeconfig"
82 | owner: "root"
83 | group: "{{ k8s_run_as_group }}"
84 | mode: "0640"
85 | modification_time: "preserve"
86 | access_time: "preserve"
87 |
88 | - name: Register checksum of kube-scheduler current kubeconfig
89 | ansible.builtin.stat:
90 | path: "{{ k8s_scheduler_conf_dir }}/kubeconfig"
91 | register: k8s_ctl__scheduler_kubeconfig_current_stat
92 |
93 | - name: Check if kubeconfig file changed
94 | when:
95 | - k8s_ctl__scheduler_kubeconfig_orig_stat.stat.checksum is defined
96 | - k8s_ctl__scheduler_kubeconfig_orig_stat.stat.checksum != k8s_ctl__scheduler_kubeconfig_current_stat.stat.checksum
97 | ansible.builtin.debug:
98 | msg: "kubeconfig file changed"
99 | changed_when:
100 | - k8s_ctl__scheduler_kubeconfig_orig_stat.stat.checksum != k8s_ctl__scheduler_kubeconfig_current_stat.stat.checksum
101 | notify:
102 | - Restart kube-scheduler
103 |
--------------------------------------------------------------------------------
/tasks/authconfig/kube-controller-manager.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Register checksum of kube-controller-manager original kubeconfig
3 | ansible.builtin.stat:
4 | path: "{{ k8s_controller_manager_conf_dir }}/kubeconfig"
5 | register: k8s_ctl__controller_manager_kubeconfig_orig_stat
6 |
7 | - name: Generate kubeconfig for kube-controller-manager (set-cluster)
8 | ansible.builtin.shell: >
9 | set -o errexit; \
10 | kubectl config set-cluster {{ k8s_config_cluster_name }} \
11 | --certificate-authority={{ k8s_ctl_pki_dir }}/ca-k8s-apiserver.pem \
12 | --embed-certs=true \
13 | --server=https://{{ k8s_ctl_api_endpoint_host }}:{{ k8s_ctl_api_endpoint_port }} \
14 | --kubeconfig={{ k8s_controller_manager_conf_dir }}/kubeconfig
15 | args:
16 | executable: /bin/bash
17 | register: k8s_ctl__set_cluster_out
18 | changed_when: false
19 | failed_when: k8s_ctl__set_cluster_out.rc != 0
20 |
21 | - name: Generate kubeconfig for kube-controller-manager (set-cluster) - DEBUG OUTPUT
22 | ansible.builtin.debug:
23 | msg: "COMMAND:{{ k8s_ctl__set_cluster_out.cmd }} | OUTPUT: {{ k8s_ctl__set_cluster_out.stdout }}"
24 | verbosity: 2
25 |
26 | - name: Generate kubeconfig for kube-controller-manager (set-credentials)
27 | ansible.builtin.shell: >
28 | set -o errexit; \
29 | kubectl config set-credentials system:kube-controller-manager \
30 | --client-certificate={{ k8s_ctl_pki_dir }}/cert-k8s-controller-manager.pem \
31 | --client-key={{ k8s_ctl_pki_dir }}/cert-k8s-controller-manager-key.pem \
32 | --embed-certs=true \
33 | --kubeconfig={{ k8s_controller_manager_conf_dir }}/kubeconfig
34 | args:
35 | executable: /bin/bash
36 | register: k8s_ctl__set_credentials_out
37 | changed_when: false
38 | failed_when: k8s_ctl__set_credentials_out.rc != 0
39 |
40 | - name: Generate kubeconfig for kube-controller-manager (set-credentials) - DEBUG OUTPUT
41 | ansible.builtin.debug:
42 | msg: "COMMAND:{{ k8s_ctl__set_credentials_out.cmd }} | OUTPUT: {{ k8s_ctl__set_credentials_out.stdout }}"
43 | verbosity: 2
44 |
45 | - name: Generate kubeconfig for kube-controller-manager (set-context)
46 | ansible.builtin.shell: >
47 | set -o errexit; \
48 | kubectl config set-context default \
49 | --cluster={{ k8s_config_cluster_name }} \
50 | --user=system:kube-controller-manager \
51 | --kubeconfig={{ k8s_controller_manager_conf_dir }}/kubeconfig
52 | args:
53 | executable: /bin/bash
54 | register: k8s_ctl__set_context_out
55 | changed_when: false
56 | failed_when: k8s_ctl__set_context_out.rc != 0
57 |
58 | - name: Generate kubeconfig for kube-controller-manager (set-context) - DEBUG OUTPUT
59 | ansible.builtin.debug:
60 | msg: "COMMAND:{{ k8s_ctl__set_context_out.cmd }} | OUTPUT: {{ k8s_ctl__set_context_out.stdout }}"
61 | verbosity: 2
62 |
63 | - name: Generate kubeconfig for kube-controller-manager (use-context)
64 | ansible.builtin.shell: >
65 | set -o errexit; \
66 | kubectl config use-context default \
67 | --kubeconfig={{ k8s_controller_manager_conf_dir }}/kubeconfig
68 | args:
69 | executable: /bin/bash
70 | register: k8s_ctl__use_context_out
71 | changed_when: false
72 | failed_when: k8s_ctl__use_context_out.rc != 0
73 |
74 | - name: Generate kubeconfig for kube-controller-manager (use-context) - DEBUG OUTPUT
75 | ansible.builtin.debug:
76 | msg: "COMMAND:{{ k8s_ctl__use_context_out.cmd }} | OUTPUT: {{ k8s_ctl__use_context_out.stdout }}"
77 | verbosity: 2
78 |
79 | - name: Set file permissions
80 | ansible.builtin.file:
81 | path: "{{ k8s_controller_manager_conf_dir }}/kubeconfig"
82 | owner: "root"
83 | group: "{{ k8s_run_as_group }}"
84 | mode: "0640"
85 | modification_time: "preserve"
86 | access_time: "preserve"
87 |
88 | - name: Register checksum of kube-controller-manager current kubeconfig
89 | ansible.builtin.stat:
90 | path: "{{ k8s_controller_manager_conf_dir }}/kubeconfig"
91 | register: k8s_ctl__controller_manager_kubeconfig_current_stat
92 |
93 | - name: Check if kubeconfig file changed
94 | when:
95 | - k8s_ctl__controller_manager_kubeconfig_orig_stat.stat.checksum is defined
96 | - k8s_ctl__controller_manager_kubeconfig_orig_stat.stat.checksum != k8s_ctl__controller_manager_kubeconfig_current_stat.stat.checksum
97 | ansible.builtin.debug:
98 | msg: "kubeconfig file changed"
99 | changed_when:
100 | - k8s_ctl__controller_manager_kubeconfig_orig_stat.stat.checksum != k8s_ctl__controller_manager_kubeconfig_current_stat.stat.checksum
101 | notify:
102 | - Restart kube-controller-manager
103 |
--------------------------------------------------------------------------------
/tasks/authconfig/kube-admin-user.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Create directory to store admin.kubeconfig file
3 | ansible.builtin.file:
4 | path: "{{ k8s_admin_conf_dir }}"
5 | state: directory
6 | mode: "{{ k8s_admin_conf_dir_perm }}"
7 | owner: "{{ k8s_admin_conf_owner }}"
8 | group: "{{ k8s_admin_conf_group }}"
9 |
10 | - name: Register checksum original admin.kubeconfig
11 | ansible.builtin.stat:
12 | path: "{{ k8s_admin_conf_dir }}/admin.kubeconfig"
13 | register: k8s_ctl__admin_kubeconfig_orig_stat
14 | run_once: true
15 | delegate_to: "{{ k8s_ctl_delegate_to }}"
16 |
17 | - name: Generate a kubeconfig file for the admin user (set-cluster)
18 | ansible.builtin.shell: >
19 | set -o errexit; \
20 | kubectl config set-cluster {{ k8s_config_cluster_name }} \
21 | --certificate-authority={{ k8s_ctl_ca_conf_directory }}/ca-k8s-apiserver.pem \
22 | --embed-certs=true \
23 | --server=https://{{ k8s_admin_api_endpoint_host }}:{{ k8s_admin_api_endpoint_port }} \
24 | --kubeconfig={{ k8s_admin_conf_dir }}/admin.kubeconfig
25 | args:
26 | executable: /bin/bash
27 | register: k8s_ctl__set_cluster_out
28 | changed_when: false
29 | failed_when: k8s_ctl__set_cluster_out.rc != 0
30 | run_once: true
31 | delegate_to: "{{ k8s_ctl_delegate_to }}"
32 |
33 | - name: Generate kubeconfig for the admin user (set-cluster) - DEBUG OUTPUT
34 | ansible.builtin.debug:
35 | msg: "COMMAND:{{ k8s_ctl__set_cluster_out.cmd }} | OUTPUT: {{ k8s_ctl__set_cluster_out.stdout }}"
36 | verbosity: 2
37 | run_once: true
38 | delegate_to: "{{ k8s_ctl_delegate_to }}"
39 |
40 | - name: Generate a kubeconfig file for the admin user (set-credentials)
41 | ansible.builtin.shell: >
42 | set -o errexit; \
43 | kubectl config set-credentials admin \
44 | --client-certificate={{ k8s_ctl_ca_conf_directory }}/cert-admin.pem \
45 | --client-key={{ k8s_ctl_ca_conf_directory }}/cert-admin-key.pem \
46 | --embed-certs=true \
47 | --kubeconfig={{ k8s_admin_conf_dir }}/admin.kubeconfig
48 | args:
49 | executable: /bin/bash
50 | register: k8s_ctl__set_credentials_out
51 | changed_when: false
52 | failed_when: k8s_ctl__set_credentials_out.rc != 0
53 | run_once: true
54 | delegate_to: "{{ k8s_ctl_delegate_to }}"
55 |
56 | - name: Generate kubeconfig for the admin user (set-credentials) - DEBUG OUTPUT
57 | ansible.builtin.debug:
58 | msg: "COMMAND:{{ k8s_ctl__set_credentials_out.cmd }} | OUTPUT: {{ k8s_ctl__set_credentials_out.stdout }}"
59 | verbosity: 2
60 | run_once: true
61 | delegate_to: "{{ k8s_ctl_delegate_to }}"
62 |
63 | - name: Generate a kubeconfig file for the admin user (set-context)
64 | ansible.builtin.shell: >
65 | set -o errexit; \
66 | kubectl config set-context default \
67 | --cluster={{ k8s_config_cluster_name }} \
68 | --user=admin \
69 | --kubeconfig={{ k8s_admin_conf_dir }}/admin.kubeconfig
70 | args:
71 | executable: /bin/bash
72 | register: k8s_ctl__set_context_out
73 | changed_when: false
74 | failed_when: k8s_ctl__set_context_out.rc != 0
75 | run_once: true
76 | delegate_to: "{{ k8s_ctl_delegate_to }}"
77 |
78 | - name: Generate kubeconfig for the admin user (set-context) - DEBUG OUTPUT
79 | ansible.builtin.debug:
80 | msg: "COMMAND:{{ k8s_ctl__set_context_out.cmd }} | OUTPUT: {{ k8s_ctl__set_context_out.stdout }}"
81 | verbosity: 2
82 | run_once: true
83 | delegate_to: "{{ k8s_ctl_delegate_to }}"
84 |
85 | - name: Set use-context
86 | ansible.builtin.shell: >
87 | kubectl config use-context default \
88 | --kubeconfig={{ k8s_admin_conf_dir }}/admin.kubeconfig
89 | args:
90 | executable: /bin/bash
91 | register: k8s_ctl__use_context_out
92 | changed_when: false
93 | failed_when: k8s_ctl__use_context_out.rc != 0
94 | run_once: true
95 | delegate_to: "{{ k8s_ctl_delegate_to }}"
96 |
97 | - name: Generate kubeconfig for the admin user (use-context) - DEBUG OUTPUT
98 | ansible.builtin.debug:
99 | msg: "COMMAND:{{ k8s_ctl__use_context_out.cmd }} | OUTPUT: {{ k8s_ctl__use_context_out.stdout }}"
100 | verbosity: 2
101 |
102 | - name: Set file permissions
103 | ansible.builtin.file:
104 | path: "{{ k8s_admin_conf_dir }}/admin.kubeconfig"
105 | owner: "{{ k8s_admin_conf_owner }}"
106 | group: "{{ k8s_admin_conf_group }}"
107 | mode: "0640"
108 | modification_time: "preserve"
109 | access_time: "preserve"
110 | run_once: true
111 | delegate_to: "{{ k8s_ctl_delegate_to }}"
112 |
113 | - name: Register checksum of current admin.kubeconfig
114 | ansible.builtin.stat:
115 | path: "{{ k8s_admin_conf_dir }}/admin.kubeconfig"
116 | register: k8s_ctl__admin_kubeconfig_current_stat
117 | run_once: true
118 | delegate_to: "{{ k8s_ctl_delegate_to }}"
119 |
120 | - name: Check if admin.kubeconfig file changed
121 | when:
122 | - k8s_ctl__admin_kubeconfig_orig_stat.stat.checksum is defined
123 | - k8s_ctl__admin_kubeconfig_orig_stat.stat.checksum != k8s_ctl__admin_kubeconfig_current_stat.stat.checksum
124 | ansible.builtin.debug:
125 | msg: "admin.kubeconfig file changed"
126 | changed_when:
127 | - k8s_ctl__admin_kubeconfig_orig_stat.stat.checksum != k8s_ctl__admin_kubeconfig_current_stat.stat.checksum
128 | run_once: true
129 | delegate_to: "{{ k8s_ctl_delegate_to }}"
130 |
--------------------------------------------------------------------------------
/molecule/default/group_vars/all.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # Copyright (C) 2023 Robert Wimmer
3 | # SPDX-License-Identifier: GPL-3.0-or-later
4 |
5 | # Use "systemd-timesyncd" for time services. It's available by default.
6 | harden_linux_ntp: "systemd-timesyncd"
7 |
8 | # Password for user "root" and "vagrant" is "vagrant" in both cases. As
9 | # "vagrant" user is available in every Vagrant Ubuntu Box just use it.
10 | harden_linux_root_password: "$6$rounds=656000$mysecretsalt$fpyQ9hMON6iKKuM0Rz10WZKNJR4OkQTVfBmd4SPrJPsU9XmgQGRtogcUnFB5FLRIitswuQFr6Tr8Mos9l7Ojm0"
11 | harden_linux_deploy_user: "vagrant"
12 | harden_linux_deploy_user_password: "$6$rounds=656000$mysecretsalt$fpyQ9hMON6iKKuM0Rz10WZKNJR4OkQTVfBmd4SPrJPsU9XmgQGRtogcUnFB5FLRIitswuQFr6Tr8Mos9l7Ojm0"
13 | harden_linux_deploy_user_home: "/home/vagrant"
14 | harden_linux_deploy_user_uid: "1000"
15 | harden_linux_deploy_user_shell: "/bin/bash"
16 |
17 | # Enable IP forwarding for IPv4 and IPv6
18 | harden_linux_sysctl_settings_user:
19 | "net.ipv4.ip_forward": 1
20 | "net.ipv6.conf.default.forwarding": 1
21 | "net.ipv6.conf.all.forwarding": 1
22 |
23 | # Let SSHd listen on port 22, allow password authentication and allow "root"
24 | # login. The last two settings are not recommended for production use but for
25 | # this test deployment it's okay as it makes debugging easier and faster.
26 | harden_linux_sshd_settings_user:
27 | "^Port ": "Port 22"
28 | "^PasswordAuthentication": "PasswordAuthentication yes"
29 | "^PermitRootLogin": "PermitRootLogin yes"
30 |
31 | # Open a few ports for ssh, Wireguard, HTTP, HTTPS and SMTP.
32 | harden_linux_ufw_rules:
33 | - rule: "allow"
34 | to_port: "22"
35 | protocol: "tcp"
36 | - rule: "allow"
37 | to_port: "51820"
38 | protocol: "udp"
39 | - rule: "allow"
40 | to_port: "80"
41 | protocol: "tcp"
42 | - rule: "allow"
43 | to_port: "443"
44 | protocol: "tcp"
45 | - rule: "allow"
46 | to_port: "25"
47 | protocol: "tcp"
48 |
49 | # Allow all traffic from the following networks.
50 | harden_linux_ufw_allow_networks:
51 | - "10.0.0.0/8"
52 | - "172.16.0.0/12"
53 | - "192.168.0.0/16"
54 |
55 | # Enable logging for UFW.
56 | harden_linux_ufw_logging: 'on'
57 |
58 | # Set the default forward policy to "ACCEPT".
59 | harden_linux_ufw_defaults_user:
60 | "^DEFAULT_FORWARD_POLICY": 'DEFAULT_FORWARD_POLICY="ACCEPT"'
61 |
62 | # Don't block SSH logins from the following networks even login attempts fail
63 | # for a few times.
64 | harden_linux_sshguard_whitelist:
65 | - "127.0.0.0/8"
66 | - "::1/128"
67 | - "10.0.0.0/8"
68 | - "172.16.0.0/12"
69 | - "192.168.0.0/16"
70 |
71 | # Directory where the etcd certificates are stored on the Ansible controller
72 | # host. Certificate files for etcd will be copied from this directory to
73 | # the etcd nodes.
74 | etcd_ca_conf_directory: "{{ k8s_ca_conf_directory }}"
75 | # Directory where the etcd certificates are stored on the etcd hosts.
76 | etcd_conf_dir: "/etc/etcd"
77 | # Interface where the etcd service is listening on.
78 | etcd_interface: "{{ k8s_interface }}"
79 | # A few additional settings for etcd.
80 | etcd_settings_user:
81 | "heartbeat-interval": "250"
82 | "election-timeout": "2500"
83 | # Host names and IP addresses in the etcd certificates.
84 | etcd_cert_hosts:
85 | - localhost
86 | - 127.0.0.1
87 | - 172.16.10.10
88 | - 172.16.10.20
89 | - 172.16.10.30
90 | - 10.10.10.10
91 | - 10.10.10.20
92 | - 10.10.10.30
93 | - test-controller1
94 | - test-controller2
95 | - test-controller3
96 |
97 | # Directory where the Kubernetes certificates are stored on the Ansible
98 | # controller host.
99 | k8s_ca_conf_directory: "/tmp/k8s-ca"
100 | # Permissions for the Kubernetes CA directory.
101 | k8s_ca_conf_directory_perm: "0700"
102 | # Permissions for the Kubernetes CA files.
103 | k8s_ca_file_perm: "0600"
104 | # Owner of the Kubernetes CA files.
105 | k8s_ca_certificate_owner: "vagrant"
106 | # Group of the Kubernetes CA files.
107 | k8s_ca_certificate_group: "vagrant"
108 |
109 | # Interface where the Kubernetes control plane services are listening on.
110 | k8s_interface: "wg0"
111 | # Interface where the etcd daemons listening on.
112 | k8s_ctl_etcd_interface: "{{ etcd_interface }}"
113 |
114 | # Delegate tasks like creating the Kubernetes CA certificates to the following
115 | # host. This host also communicates with the "kube-apiserver" if required
116 | # for certain tasks.
117 | k8s_ctl_delegate_to: "test-assets"
118 |
119 | # Directory where the Kubernetes certificates are stored on the Ansible
120 | # controller host and where the Ansible can find them to be copied to the
121 | # Kubernetes control plane nodes.
122 | k8s_ctl_ca_conf_directory: "{{ k8s_ca_conf_directory }}"
123 |
124 | # The name of the Kubernetes cluster.
125 | k8s_config_cluster_name: "k8s"
126 |
127 | # Directory where "admin.kubeconfig" (the credentials file) for the "admin"
128 | # user is stored
129 | k8s_admin_conf_dir: "{{ '~/k8s/configs' | expanduser }}"
130 | # Permissions for the directory specified in "k8s_admin_conf_dir"
131 | k8s_admin_conf_dir_perm: "0700"
132 | # Owner of the directory specified in "k8s_admin_conf_dir" and for
133 | # "admin.kubeconfig" stored in this directory.
134 | k8s_admin_conf_owner: "root"
135 | # Group of the directory specified in "k8s_admin_conf_dir" and for
136 | # "admin.kubeconfig" stored in this directory.
137 | k8s_admin_conf_group: "root"
138 |
139 | # Run Kubernetes control plane services as the following user.
140 | k8s_run_as_user: "k8s"
141 | # Run Kubernetes control plane services as the following group.
142 | k8s_run_as_group: "k8s"
143 |
144 | # Key used for encrypting secrets (encryption at-rest) by the
145 | # "kube-apiserver".
146 | k8s_encryption_config_key: "Y29uZmlndXJhdGlvbjIyCg=="
147 |
148 | # Additional settings for the "kube-apiserver".
149 | k8s_apiserver_settings_user:
150 | "enable-aggregator-routing": "true"
151 |
152 | # Directory for the "runc" binaries
153 | runc_bin_directory: "/usr/local/sbin"
154 |
155 | # Common name for "etcd" certificate authority certificates.
156 | ca_etcd_csr_cn: "etcd"
157 | ca_etcd_csr_key_algo: "ecdsa"
158 | ca_etcd_csr_key_size: "384"
159 |
160 | # Common name for "kube-apiserver" certificate authority certificate.
161 | ca_k8s_apiserver_csr_cn: "kubernetes"
162 | ca_k8s_apiserver_csr_key_algo: "ecdsa"
163 | ca_k8s_apiserver_csr_key_size: "384"
164 |
165 | # Common names for "etcd" server, peer and client certificates.
166 | etcd_server_csr_cn: "etcd-server"
167 | etcd_server_csr_key_algo: "ecdsa"
168 | etcd_server_csr_key_size: "384"
169 |
170 | etcd_peer_csr_cn: "etcd-peer"
171 | etcd_peer_csr_key_algo: "ecdsa"
172 | etcd_peer_csr_key_size: "384"
173 |
174 | etcd_client_csr_cn_prefix: "etcd-client"
175 | etcd_client_csr_key_algo: "ecdsa"
176 | etcd_client_csr_key_size: "384"
177 |
178 | # Common names for kube-apiserver, admin and kube-controller-manager certificates.
179 | k8s_apiserver_csr_cn: "k8s-apiserver"
180 | k8s_apiserver_csr_key_algo: "ecdsa"
181 | k8s_apiserver_csr_key_size: "384"
182 |
183 | k8s_admin_csr_cn: "k8s-admin"
184 | k8s_admin_csr_key_algo: "ecdsa"
185 | k8s_admin_csr_key_size: "384"
186 |
187 | k8s_worker_csr_key_algo: "ecdsa"
188 | k8s_worker_csr_key_size: "384"
189 |
190 | k8s_controller_manager_csr_key_algo: "ecdsa"
191 | k8s_controller_manager_csr_key_size: "384"
192 |
193 | k8s_scheduler_csr_key_algo: "ecdsa"
194 | k8s_scheduler_csr_key_size: "384"
195 |
196 | k8s_controller_manager_sa_csr_cn: "k8s-service-accounts"
197 | k8s_controller_manager_sa_csr_key_algo: "ecdsa"
198 | k8s_controller_manager_sa_csr_key_size: "384"
199 |
200 | k8s_kube_proxy_csr_key_algo: "ecdsa"
201 | k8s_kube_proxy_csr_key_size: "384"
202 |
--------------------------------------------------------------------------------
/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Create group that runs K8s Control Plane processes
3 | when:
4 | - k8s_run_as_group != "root"
5 | ansible.builtin.group:
6 | name: "{{ k8s_run_as_group }}"
7 | state: present
8 | system: "{{ k8s_run_as_group_system }}"
9 | gid: "{{ k8s_run_as_group_gid | default(omit) }}"
10 | tags:
11 | - k8s-controller
12 | - k8s-controller-base
13 |
14 | - name: Create user that runs K8s Control Plane processes
15 | when:
16 | - k8s_run_as_user != "root"
17 | ansible.builtin.user:
18 | name: "{{ k8s_run_as_user }}"
19 | state: present
20 | shell: "{{ k8s_run_as_user_shell }}"
21 | system: "{{ k8s_run_as_user_system | bool }}"
22 | create_home: "{{ k8s_run_as_user_home is defined and k8s_run_as_user_system != true }}"
23 | home: "{{ k8s_run_as_user_home | default(omit) }}"
24 | uid: "{{ k8s_run_as_user_uid | default(omit) }}"
25 | group: "{{ k8s_run_as_group }}"
26 | tags:
27 | - k8s-controller
28 | - k8s-controller-base
29 |
30 | - name: Create base directory for K8s services log files
31 | ansible.builtin.file:
32 | path: "{{ k8s_ctl_log_base_dir }}"
33 | state: directory
34 | mode: "{{ k8s_ctl_log_base_dir_mode }}"
35 | owner: "{{ k8s_run_as_user }}"
36 | group: "{{ k8s_run_as_group }}"
37 | tags:
38 | - k8s-controller
39 | - k8s-controller-base
40 |
41 | - name: Create directory to store kube-apiserver audit logs
42 | ansible.builtin.file:
43 | path: "{{ k8s_apiserver_audit_log_dir }}"
44 | state: directory
45 | mode: "0750"
46 | owner: "{{ k8s_run_as_user }}"
47 | group: "{{ k8s_run_as_group }}"
48 | tags:
49 | - k8s-controller
50 | - k8s-controller-base
51 |
52 | - name: Create directory for K8s control plane binaries
53 | ansible.builtin.file:
54 | path: "{{ k8s_ctl_bin_dir }}"
55 | state: directory
56 | mode: "0755"
57 | owner: "root"
58 | group: "root"
59 | tags:
60 | - k8s-controller
61 | - k8s-controller-base
62 |
63 | - name: Create control plane configuration base directory
64 | ansible.builtin.file:
65 | path: "{{ k8s_ctl_conf_dir }}"
66 | state: directory
67 | mode: "0750"
68 | owner: "root"
69 | group: "{{ k8s_run_as_group }}"
70 | tags:
71 | - k8s-controller
72 | - k8s-controller-base
73 |
74 | - name: Create PKI directory
75 | ansible.builtin.file:
76 | path: "{{ k8s_ctl_pki_dir }}"
77 | state: directory
78 | mode: "0750"
79 | owner: "root"
80 | group: "{{ k8s_run_as_group }}"
81 | tags:
82 | - k8s-controller
83 | - k8s-controller-base
84 |
85 | - name: Create kube-apiserver config directory
86 | ansible.builtin.file:
87 | path: "{{ k8s_apiserver_conf_dir }}"
88 | state: directory
89 | mode: "0750"
90 | owner: "root"
91 | group: "{{ k8s_run_as_group }}"
92 | tags:
93 | - k8s-controller
94 | - k8s-controller-base
95 |
96 | - name: Create kube-controller-manager config directory
97 | ansible.builtin.file:
98 | path: "{{ k8s_controller_manager_conf_dir }}"
99 | state: directory
100 | mode: "0750"
101 | owner: "root"
102 | group: "{{ k8s_run_as_group }}"
103 | tags:
104 | - k8s-controller
105 | - k8s-controller-base
106 |
107 | - name: Create kube-scheduler config directory
108 | ansible.builtin.file:
109 | path: "{{ k8s_scheduler_conf_dir }}"
110 | state: directory
111 | mode: "0750"
112 | owner: "root"
113 | group: "{{ k8s_run_as_group }}"
114 | tags:
115 | - k8s-controller
116 | - k8s-controller-base
117 |
118 | - name: Create kube-scheduler.yaml
119 | ansible.builtin.template:
120 | src: "templates/etc/kubernetes/controller/kube-scheduler/kube-scheduler.yaml.j2"
121 | dest: "{{ k8s_scheduler_conf_dir }}/kube-scheduler.yaml"
122 | mode: "0440"
123 | owner: "root"
124 | group: "{{ k8s_run_as_group }}"
125 | tags:
126 | - k8s-controller
127 | - k8s-controller-base
128 |
129 | - name: Copy etcd certificates
130 | ansible.builtin.copy:
131 | src: "{{ k8s_ctl_ca_conf_directory }}/{{ item }}"
132 | dest: "{{ k8s_ctl_pki_dir }}/{{ item }}"
133 | mode: "0440"
134 | owner: "root"
135 | group: "{{ k8s_run_as_group }}"
136 | with_items:
137 | - "{{ k8s_ctl_etcd_certificates }}"
138 | tags:
139 | - k8s-controller
140 | - k8s-controller-base
141 |
142 | - name: Copy Kubernetes certificates
143 | ansible.builtin.copy:
144 | src: "{{ k8s_ctl_ca_conf_directory }}/{{ item }}"
145 | dest: "{{ k8s_ctl_pki_dir }}/{{ item }}"
146 | mode: "0440"
147 | owner: "root"
148 | group: "{{ k8s_run_as_group }}"
149 | with_items:
150 | - "{{ k8s_ctl_certificates }}"
151 | tags:
152 | - k8s-controller
153 | - k8s-controller-base
154 |
155 | - name: Downloading official Kubernetes binaries
156 | ansible.builtin.get_url:
157 | url: "https://dl.k8s.io/v{{ k8s_ctl_release }}/bin/linux/amd64/{{ item }}"
158 | checksum: "sha512:https://dl.k8s.io/v{{ k8s_ctl_release }}/bin/linux/amd64/{{ item }}.sha512"
159 | dest: "{{ k8s_ctl_bin_dir }}"
160 | owner: "root"
161 | group: "root"
162 | mode: "0755"
163 | with_items:
164 | - "{{ k8s_ctl_binaries }}"
165 | notify:
166 | - Restart kube-apiserver
167 | - Restart kube-controller-manager
168 | - Restart kube-scheduler
169 | tags:
170 | - k8s-controller
171 |
172 | - name: Create kube-scheduler kubeconfig
173 | ansible.builtin.include_tasks:
174 | file: "authconfig/kube-scheduler.yml"
175 | tags:
176 | - k8s-controller
177 | - k8s-controller-auth-config-scheduler
178 |
179 | - name: Create kube-controller-manager kubeconfig
180 | ansible.builtin.include_tasks:
181 | file: "authconfig/kube-controller-manager.yml"
182 | tags:
183 | - k8s-controller
184 | - k8s-controller-auth-config-controller-manager
185 |
186 | - name: Create admin user kubeconfig
187 | ansible.builtin.include_tasks:
188 | file: "authconfig/kube-admin-user.yml"
189 | tags:
190 | - k8s-controller
191 | - k8s-controller-auth-config-admin-user
192 |
193 | - name: Create encryption-config.yaml
194 | ansible.builtin.copy:
195 | content: "{{ k8s_apiserver_encryption_provider_config }}"
196 | dest: "{{ k8s_apiserver_conf_dir }}/encryption-config.yaml"
197 | mode: "0660"
198 | owner: "root"
199 | group: "{{ k8s_run_as_group }}"
200 | tags:
201 | - k8s-controller
202 | - k8s-controller-base
203 |
204 | - name: Combine k8s_apiserver_settings and k8s_apiserver_settings_user (if defined)
205 | ansible.builtin.set_fact:
206 | k8s_apiserver_settings: "{{ k8s_apiserver_settings | combine(k8s_apiserver_settings_user | default({})) | combine({'etcd-servers': k8s_ctl__etcd_servers}) }}"
207 | vars:
208 | k8s_ctl__etcd_servers: "{% for host in groups['k8s_etcd'] %}https://{{ hostvars[host]['ansible_' + k8s_ctl_etcd_interface].ipv4.address }}:{{ k8s_ctl_etcd_client_port }}{% if not loop.last %},{% endif %}{% endfor %}"
209 | tags:
210 | - k8s-controller
211 |
212 | - name: Create systemd unit file for kube-apiserver
213 | ansible.builtin.template:
214 | src: etc/systemd/system/kube-apiserver.service.j2
215 | dest: /etc/systemd/system/kube-apiserver.service
216 | owner: root
217 | group: root
218 | mode: "0644"
219 | notify:
220 | - Reload systemd
221 | - Restart kube-apiserver
222 | tags:
223 | - k8s-controller
224 |
225 | - name: Enable and start kube-apiserver
226 | ansible.builtin.service:
227 | name: kube-apiserver
228 | enabled: true
229 | state: started
230 | tags:
231 | - k8s-controller
232 |
233 | - name: Combine k8s_controller_manager_settings and k8s_controller_manager_settings_user (if defined)
234 | ansible.builtin.set_fact:
235 | k8s_controller_manager_settings: "{{ k8s_controller_manager_settings | combine(k8s_controller_manager_settings_user | default({})) }}"
236 | tags:
237 | - k8s-controller
238 |
239 | - name: Create systemd unit file for kube-controller-manager
240 | ansible.builtin.template:
241 | src: etc/systemd/system/kube-controller-manager.service.j2
242 | dest: /etc/systemd/system/kube-controller-manager.service
243 | owner: root
244 | group: root
245 | mode: "0644"
246 | notify:
247 | - Reload systemd
248 | - Restart kube-controller-manager
249 | tags:
250 | - k8s-controller
251 |
252 | - name: Enable and start kube-controller-manager
253 | ansible.builtin.service:
254 | name: kube-controller-manager
255 | enabled: true
256 | state: started
257 | tags:
258 | - k8s-controller
259 |
260 | - name: Combine k8s_scheduler_settings and k8s_scheduler_settings_user (if defined)
261 | ansible.builtin.set_fact:
262 | k8s_scheduler_settings: "{{ k8s_scheduler_settings | combine(k8s_scheduler_settings_user | default({})) }}"
263 | tags:
264 | - k8s-controller
265 |
266 | - name: Create systemd unit file for kube-scheduler
267 | ansible.builtin.template:
268 | src: etc/systemd/system/kube-scheduler.service.j2
269 | dest: /etc/systemd/system/kube-scheduler.service
270 | owner: root
271 | group: root
272 | mode: "0644"
273 | notify:
274 | - Reload systemd
275 | - Restart kube-scheduler
276 | tags:
277 | - k8s-controller
278 |
279 | - name: Enable and start kube-scheduler
280 | ansible.builtin.service:
281 | name: kube-scheduler
282 | enabled: true
283 | state: started
284 | tags:
285 | - k8s-controller
286 |
287 | - name: Flush handlers
288 | ansible.builtin.meta: flush_handlers
289 |
290 | - name: Wait 300 seconds for kube-apiserver to become ready
291 | ansible.builtin.wait_for:
292 | host: "{{ k8s_ctl_api_endpoint_host }}"
293 | port: "{{ k8s_ctl_api_endpoint_port }}"
294 | delay: 5
295 | tags:
296 | - k8s-controller
297 |
298 | - name: Apply kube-apiserver-to-kubelet ClusterRole and ClusterRoleBinding
299 | tags:
300 | - k8s-controller
301 | block:
302 | - name: Create temporary directory
303 | ansible.builtin.tempfile:
304 | state: directory
305 | register: k8s_ctl__tmp_dir
306 | delegate_to: "{{ k8s_ctl_delegate_to }}"
307 | changed_when: false
308 |
309 | - name: Change temporary directory permissions
310 | ansible.builtin.file:
311 | path: "{{ k8s_ctl__tmp_dir.path }}"
312 | state: directory
313 | mode: "0755"
314 | run_once: true
315 | delegate_to: "{{ k8s_ctl_delegate_to }}"
316 | changed_when: false
317 |
318 | - name: Copy kube-apiserver-to-kubelet ClusterRole
319 | ansible.builtin.template:
320 | src: "rbac/kube-apiserver-to-kubelet_cluster_role.yaml.j2"
321 | dest: "{{ k8s_ctl__tmp_dir.path }}/kube-apiserver-to-kubelet_cluster_role.yaml"
322 | mode: "0644"
323 | run_once: true
324 | delegate_to: "{{ k8s_ctl_delegate_to }}"
325 | changed_when: false
326 |
327 | - name: Copy kube-apiserver-to-kubelet ClusterRoleBinding
328 | ansible.builtin.template:
329 | src: "rbac/kube-apiserver-to-kubelet_cluster_role_binding.yaml.j2"
330 | dest: "{{ k8s_ctl__tmp_dir.path }}/kube-apiserver-to-kubelet_cluster_role_binding.yaml"
331 | mode: "0644"
332 | run_once: true
333 | delegate_to: "{{ k8s_ctl_delegate_to }}"
334 | changed_when: false
335 |
336 | - name: Apply kube-apiserver-to-kubelet ClusterRole
337 | kubernetes.core.k8s:
338 | state: present
339 | src: "{{ k8s_ctl__tmp_dir.path }}/kube-apiserver-to-kubelet_cluster_role.yaml"
340 | kubeconfig: "{{ k8s_admin_conf_dir }}/admin.kubeconfig"
341 | run_once: true
342 | delegate_to: "{{ k8s_ctl_delegate_to }}"
343 | changed_when: false
344 |
345 | - name: Apply kube-apiserver-to-kubelet ClusterRoleBinding
346 | kubernetes.core.k8s:
347 | state: present
348 | src: "{{ k8s_ctl__tmp_dir.path }}/kube-apiserver-to-kubelet_cluster_role_binding.yaml"
349 | kubeconfig: "{{ k8s_admin_conf_dir }}/admin.kubeconfig"
350 | run_once: true
351 | delegate_to: "{{ k8s_ctl_delegate_to }}"
352 | changed_when: false
353 |
354 | always:
355 | - name: Remove temporary files
356 | ansible.builtin.file:
357 | path: "{{ k8s_ctl__tmp_dir.path }}"
358 | state: absent
359 | run_once: true
360 | delegate_to: "{{ k8s_ctl_delegate_to }}"
361 | changed_when: false
362 |
--------------------------------------------------------------------------------
/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # The base directory for Kubernetes configuration and certificate files for
3 | # everything control plane related. After the playbook is done this directory
4 | # contains various sub-folders.
5 | k8s_ctl_conf_dir: "/etc/kubernetes/controller"
6 |
7 | # All certificate files (Private Key Infrastructure related) specified in
8 | # "k8s_ctl_certificates" and "k8s_ctl_etcd_certificates" (see "vars/main.yml")
9 | # will be stored here. Owner of this new directory will be "root". Group will
10 | # be the group specified in "k8s_run_as_group"`. The files in this directory
11 | # will be owned by "root" and group as specified in "k8s_run_as_group"`. File
12 | # permissions will be "0640".
13 | k8s_ctl_pki_dir: "{{ k8s_ctl_conf_dir }}/pki"
14 |
15 | # The directory to store the Kubernetes binaries (see "k8s_ctl_binaries"
16 | # variable in "vars/main.yml"). Owner and group of this new directory
17 | # will be "root" in both cases. Permissions for this directory will be "0755".
18 | #
19 | # NOTE: The default directory "/usr/local/bin" normally already exists on every
20 | # Linux installation with the owner, group and permissions mentioned above. If
21 | # your current settings are different consider a different directory. But make sure
22 | # that the new directory is included in your "$PATH" variable value.
23 | k8s_ctl_bin_dir: "/usr/local/bin"
24 |
25 | # The Kubernetes release.
26 | k8s_ctl_release: "1.33.6"
27 |
28 | # The interface on which the Kubernetes services should listen on. As all cluster
29 | # communication should use a VPN interface the interface name is
30 | # normally "wg0" (WireGuard),"peervpn0" (PeerVPN) or "tap0".
31 | #
32 | # The network interface on which the Kubernetes control plane services should
33 | # listen on. That is:
34 | #
35 | # - kube-apiserver
36 | # - kube-scheduler
37 | # - kube-controller-manager
38 | #
39 | k8s_interface: "eth0"
40 |
41 | # Run Kubernetes control plane service (kube-apiserver, kube-scheduler,
42 | # kube-controller-manager) as this user.
43 | #
44 | # If you want to use a "secure-port" < 1024 for "kube-apiserver" you most
45 | # probably need to run "kube-apiserver" as user "root" (not recommended).
46 | #
47 | # If the user specified in "k8s_run_as_user" does not exist then the role
48 | # will create it. Only if the user already exists the role will not create it
49 | # but it will adjust it's UID/GID and shell if specified (see settings below).
50 | # So make sure that UID, GID and shell matches the existing user if you don't
51 | # want that that user will be changed.
52 | #
53 | # Additionally if "k8s_run_as_user" is "root" then this role wont touch the user
54 | # at all.
55 | k8s_run_as_user: "k8s"
56 |
57 | # UID of user specified in "k8s_run_as_user". If not specified the next available
58 | # UID from "/etc/login.defs" will be taken (see "SYS_UID_MAX" setting in that file).
59 | # k8s_run_as_user_uid: "999"
60 |
61 | # Shell for specified user in "k8s_run_as_user". For increased security keep
62 | # the default.
63 | k8s_run_as_user_shell: "/bin/false"
64 |
65 | # Specifies if the user specified in "k8s_run_as_user" will be a system user (default)
66 | # or not. If "true" the "k8s_run_as_user_home" setting will be ignored. In general
67 | # it makes sense to keep the default as there should be no need to login as
68 | # the user that runs kube-apiserver, kube-scheduler or kube-controller-manager.
69 | k8s_run_as_user_system: true
70 |
71 | # Home directory of user specified in "k8s_run_as_user". Will be ignored if
72 | # "k8s_run_as_user_system" is set to "true". In this case no home directory will
73 | # be created. Normally not needed.
74 | # k8s_run_as_user_home: "/home/k8s"
75 |
76 | # Run Kubernetes daemons (kube-apiserver, kube-scheduler, kube-controller-manager)
77 | # as this group.
78 | #
79 | # Note: If the group specified in "k8s_run_as_group" does not exist then the role
80 | # will create it. Only if the group already exists the role will not create it
81 | # but will adjust GID if specified in "k8s_run_as_group_gid" (see setting below).
82 | k8s_run_as_group: "k8s"
83 |
84 | # GID of group specified in "k8s_run_as_group". If not specified the next available
85 | # GID from "/etc/login.defs" will be take (see "SYS_GID_MAX" setting in that file).
86 | # k8s_run_as_group_gid: "999"
87 |
88 | # Specifies if the group specified in "k8s_run_as_group" will be a system group (default)
89 | # or not.
90 | k8s_run_as_group_system: true
91 |
92 | # By default all tasks that needs to communicate with the Kubernetes
93 | # cluster are executed on local host (127.0.0.1). But if that one
94 | # doesn't have direct connection to the K8s cluster or should be executed
95 | # elsewhere this variable can be changed accordingly.
96 | k8s_ctl_delegate_to: "127.0.0.1"
97 |
98 | # The IP address or hostname of the Kubernetes API endpoint. This variable
99 | # is used by "kube-scheduler" and "kube-controller-manager" to connect
100 | # to the "kube-apiserver" (Kubernetes API server).
101 | #
102 | # By default the first host in the Ansible group "k8s_controller" is
103 | # specified here. NOTE: This setting is not fault tolerant! That means
104 | # if the first host in the Ansible group "k8s_controller" is down
105 | # the worker node and its workload continue working but the worker
106 | # node doesn't receive any updates from Kubernetes API server.
107 | #
108 | # If you have a loadbalancer that distributes traffic between all
109 | # Kubernetes API servers it should be specified here (either its IP
110 | # address or the DNS name). But you need to make sure that the IP
111 | # address or the DNS name you want to use here is included in the
112 | # Kubernetes API server TLS certificate (see "k8s_apiserver_cert_hosts"
113 | # variable of https://github.com/githubixx/ansible-role-kubernetes-ca
114 | # role). If it's not specified you'll get certificate errors in the
115 | # logs of the services mentioned above.
116 | k8s_ctl_api_endpoint_host: "{{ hostvars[groups['k8s_controller'] | first]['ansible_' + hostvars[groups['k8s_controller'] | first]['k8s_interface']].ipv4.address }}"
117 |
118 | # As above just for the port. It specifies on which port the
119 | # Kubernetes API servers are listening. Again if there is a loadbalancer
120 | # in place that distributes the requests to the Kubernetes API servers
121 | # put the port of the loadbalancer here.
122 | k8s_ctl_api_endpoint_port: "6443"
123 |
124 | # Normally "kube-apiserver", "kube-controller-manager" and "kube-scheduler" log
125 | # to "journald". But there are exceptions like the audit log. For this kind of
126 | # log files this directory will be used as a base path. The owner and group
127 | # of this directory will be the one specified in "k8s_run_as_user" and "k8s_run_as_group"
128 | # as these services run as this user and need permissions to create log files
129 | # in this directory.
130 | k8s_ctl_log_base_dir: "/var/log/kubernetes"
131 |
132 | # Permissions for directory specified in "k8s_ctl_log_base_dir"
133 | k8s_ctl_log_base_dir_mode: "0770"
134 |
135 | # The port the control plane components should connect to etcd cluster
136 | k8s_ctl_etcd_client_port: "2379"
137 |
138 | # The interface the etcd cluster is listening on
139 | k8s_ctl_etcd_interface: "eth0"
140 |
141 | # The location of the directory where the Kubernetes certificates are stored.
142 | # These certificates were generated by the "kubernetes_ca" Ansible role if you
143 | # haven't used a different method to generate these certificates. So this
144 | # directory is located on the Ansible controller host. That's normally the
145 | # host where "ansible-playbook" gets executed. "k8s_ca_conf_directory" is used
146 | # by the "kubernetes_ca" Ansible role to store the certificates. So it's
147 | # assumed that this variable is already set.
148 | k8s_ctl_ca_conf_directory: "{{ k8s_ca_conf_directory }}"
149 |
150 | # Directory where "admin.kubeconfig" (the credentials file) for the "admin" user
151 | # is stored. By default this directory (and it's "kubeconfig" file) will
152 | # be stored on the host specified in "k8s_ctl_delegate_to". By default this
153 | # is "127.0.0.1". So if you run "ansible-playbook" locally e.g. the directory
154 | # and file will be created there.
155 | #
156 | # By default the value of this variable will expand to the user's local $HOME
157 | # plus "/k8s/certs". That means if the user's $HOME directory is e.g.
158 | # "/home/da_user" then "k8s_admin_conf_dir" will have a value of
159 | # "/home/da_user/k8s/certs".
160 | k8s_admin_conf_dir: "{{ '~/k8s/configs' | expanduser }}"
161 |
162 | # Permissions for the directory specified in "k8s_admin_conf_dir"
163 | k8s_admin_conf_dir_perm: "0700"
164 |
165 | # Owner of the directory specified in "k8s_admin_conf_dir" and for
166 | # "admin.kubeconfig" stored in this directory.
167 | k8s_admin_conf_owner: "root"
168 |
169 | # Group of the directory specified in "k8s_admin_conf_dir" and for
170 | # "admin.kubeconfig" stored in this directory.
171 | k8s_admin_conf_group: "root"
172 |
173 | # Host where the "admin" user connects to administer the K8s cluster.
174 | # This setting is written into "admin.kubeconfig". This allows to use
175 | # a different host/loadbalancer as the K8s services which might use an internal
176 | # loadbalancer while the "admin" user connects to a different host/loadbalancer
177 | # that distributes traffic to the "kube-apiserver" e.g.
178 | #
179 | # Besides that basically the same comments as for "k8s_ctl_api_endpoint_host"
180 | # variable apply.
181 | k8s_admin_api_endpoint_host: "{{ hostvars[groups['k8s_controller'] | first]['ansible_' + hostvars[groups['k8s_controller'] | first]['k8s_interface']].ipv4.address }}"
182 |
183 | # As above just for the port.
184 | k8s_admin_api_endpoint_port: "6443"
185 |
186 | # Directory to store "kube-apiserver" audit logs (if enabled). The owner and
187 | # group of this directory will be the one specified in "k8s_run_as_user"
188 | # and "k8s_run_as_group".
189 | k8s_apiserver_audit_log_dir: "{{ k8s_ctl_log_base_dir }}/kube-apiserver"
190 |
191 | # The directory to store "kube-apiserver" configuration.
192 | k8s_apiserver_conf_dir: "{{ k8s_ctl_conf_dir }}/kube-apiserver"
193 |
194 | # "kube-apiserver" daemon settings (can be overridden or additional added by defining
195 | # "k8s_apiserver_settings_user")
196 | k8s_apiserver_settings:
197 | "advertise-address": "{{ hostvars[inventory_hostname]['ansible_' + k8s_interface].ipv4.address }}"
198 | "bind-address": "{{ hostvars[inventory_hostname]['ansible_' + k8s_interface].ipv4.address }}"
199 | "secure-port": "6443"
200 | "enable-admission-plugins": "{{ k8s_apiserver_admission_plugins | join(',') }}"
201 | "allow-privileged": "true"
202 | "authorization-mode": "Node,RBAC"
203 | "audit-log-maxage": "30"
204 | "audit-log-maxbackup": "3"
205 | "audit-log-maxsize": "100"
206 | "audit-log-path": "{{ k8s_apiserver_audit_log_dir }}/audit.log"
207 | "event-ttl": "1h"
208 | "kubelet-preferred-address-types": "InternalIP,Hostname,ExternalIP" # "--kubelet-preferred-address-types" defaults to:
209 | # "Hostname,InternalDNS,InternalIP,ExternalDNS,ExternalIP"
210 | # Needs to be changed to make "kubectl logs" and "kubectl exec" work.
211 | "runtime-config": "api/all=true"
212 | "service-cluster-ip-range": "10.32.0.0/16"
213 | "service-node-port-range": "30000-32767"
214 | "client-ca-file": "{{ k8s_ctl_pki_dir }}/ca-k8s-apiserver.pem"
215 | "etcd-cafile": "{{ k8s_ctl_pki_dir }}/ca-etcd.pem"
216 | "etcd-certfile": "{{ k8s_ctl_pki_dir }}/cert-k8s-apiserver-etcd.pem"
217 | "etcd-keyfile": "{{ k8s_ctl_pki_dir }}/cert-k8s-apiserver-etcd-key.pem"
218 | "encryption-provider-config": "{{ k8s_apiserver_conf_dir }}/encryption-config.yaml"
219 | "encryption-provider-config-automatic-reload": "true"
220 | "kubelet-certificate-authority": "{{ k8s_ctl_pki_dir }}/ca-k8s-apiserver.pem"
221 | "kubelet-client-certificate": "{{ k8s_ctl_pki_dir }}/cert-k8s-apiserver.pem"
222 | "kubelet-client-key": "{{ k8s_ctl_pki_dir }}/cert-k8s-apiserver-key.pem"
223 | "service-account-key-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-controller-manager-sa.pem"
224 | "service-account-signing-key-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-controller-manager-sa-key.pem"
225 | "service-account-issuer": "https://{{ groups.k8s_controller | first }}:6443"
226 | "tls-cert-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-apiserver.pem"
227 | "tls-private-key-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-apiserver-key.pem"
228 |
229 | # kube-apiserver admission plugins used in "k8s_apiserver_settings" variable
230 | # for "enable-admission-plugins" key.
231 | k8s_apiserver_admission_plugins:
232 | - NodeRestriction
233 | - NamespaceLifecycle
234 | - LimitRanger
235 | - ServiceAccount
236 | - TaintNodesByCondition
237 | - Priority
238 | - DefaultTolerationSeconds
239 | - DefaultStorageClass
240 | - PersistentVolumeClaimResize
241 | - MutatingAdmissionWebhook
242 | - ValidatingAdmissionWebhook
243 | - ResourceQuota
244 | - PodSecurity
245 | - StorageObjectInUseProtection
246 | - RuntimeClass
247 | - CertificateApproval
248 | - CertificateSigning
249 | - ClusterTrustBundleAttest
250 | - CertificateSubjectRestriction
251 | - DefaultIngressClass
252 |
253 | # This is the content of "encryption-config.yaml". Used by "kube-apiserver"
254 | # (see "encryption-provider-config" option in "k8s_apiserver_settings").
255 | # "kube-apiserver" will use this configuration to encrypt data before storing
256 | # it in etcd (encrypt data at-rest).
257 | #
258 | # The configuration below is a usable example but might not fit your needs.
259 | # So please review carefully! E.g. you might want to replace "aescbc" provider
260 | # with a different one like "secretbox". As you can see this configuration only
261 | # encrypts "secrets" at-rest. But it's also possible to encrypt other K8s
262 | # resources. NOTE: "identity" provider doesn't encrypt anything! That means
263 | # plain text. In the configuration below it's used as fallback.
264 | #
265 | # If you keep the default defined below please make sure to specify the
266 | # variable "k8s_encryption_config_key" somewhere (e.g. "group_vars/all.yml" or
267 | # even better use "ansible-vault" to store these kind of secrets).
268 | # This needs to be a base64 encoded value. To create such a value on Linux
269 | # run the following command:
270 | #
271 | # head -c 32 /dev/urandom | base64
272 | #
273 | # For a detailed description please visit:
274 | # https://kubernetes.io/docs/tasks/administer-cluster/encrypt-data/
275 | #
276 | # How to rotate the encryption key or to implement encryption at-rest in
277 | # an existing K8s cluster please visit:
278 | # https://kubernetes.io/docs/tasks/administer-cluster/encrypt-data/#rotating-a-decryption-key
279 | k8s_apiserver_encryption_provider_config: |
280 | ---
281 | kind: EncryptionConfiguration
282 | apiVersion: apiserver.config.k8s.io/v1
283 | resources:
284 | - resources:
285 | - secrets
286 | providers:
287 | - aescbc:
288 | keys:
289 | - name: key1
290 | secret: {{ k8s_encryption_config_key }}
291 | - identity: {}
292 |
293 | # The directory to store controller manager configuration.
294 | k8s_controller_manager_conf_dir: "{{ k8s_ctl_conf_dir }}/kube-controller-manager"
295 |
296 | # K8s controller manager settings (can be overridden or additional added by defining
297 | # "k8s_controller_manager_settings_user")
298 | k8s_controller_manager_settings:
299 | "bind-address": "{{ hostvars[inventory_hostname]['ansible_' + k8s_interface].ipv4.address }}"
300 | "secure-port": "10257"
301 | "cluster-cidr": "10.200.0.0/16"
302 | "allocate-node-cidrs": "true"
303 | "cluster-name": "kubernetes"
304 | "authentication-kubeconfig": "{{ k8s_controller_manager_conf_dir }}/kubeconfig"
305 | "authorization-kubeconfig": "{{ k8s_controller_manager_conf_dir }}/kubeconfig"
306 | "kubeconfig": "{{ k8s_controller_manager_conf_dir }}/kubeconfig"
307 | "leader-elect": "true"
308 | "service-cluster-ip-range": "10.32.0.0/16"
309 | "cluster-signing-cert-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-apiserver.pem"
310 | "cluster-signing-key-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-apiserver-key.pem"
311 | "root-ca-file": "{{ k8s_ctl_pki_dir }}/ca-k8s-apiserver.pem"
312 | "requestheader-client-ca-file": "{{ k8s_ctl_pki_dir }}/ca-k8s-apiserver.pem"
313 | "service-account-private-key-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-controller-manager-sa-key.pem"
314 | "use-service-account-credentials": "true"
315 | "client-ca-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-apiserver.pem"
316 | "tls-cert-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-controller-manager.pem"
317 | "tls-private-key-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-controller-manager-key.pem"
318 |
319 | # The directory to store scheduler configuration.
320 | k8s_scheduler_conf_dir: "{{ k8s_ctl_conf_dir }}/kube-scheduler"
321 |
322 | # kube-scheduler settings
323 | k8s_scheduler_settings:
324 | "bind-address": "{{ hostvars[inventory_hostname]['ansible_' + k8s_interface].ipv4.address }}"
325 | "config": "{{ k8s_scheduler_conf_dir }}/kube-scheduler.yaml"
326 | "authentication-kubeconfig": "{{ k8s_scheduler_conf_dir }}/kubeconfig"
327 | "authorization-kubeconfig": "{{ k8s_scheduler_conf_dir }}/kubeconfig"
328 | "requestheader-client-ca-file": "{{ k8s_ctl_pki_dir }}/ca-k8s-apiserver.pem"
329 | "client-ca-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-apiserver.pem"
330 | "tls-cert-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-scheduler.pem"
331 | "tls-private-key-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-scheduler-key.pem"
332 |
333 | # These sandbox security/sandbox related settings will be used for
334 | # "kube-apiserver", "kube-scheduler" and "kube-controller-manager"
335 | # systemd units. These options will be placed in the "[Service]" section.
336 | # The default settings should be just fine for increased security of the
337 | # mentioned services. So it makes sense to keep them if possible.
338 | #
339 | # For more information see:
340 | # https://www.freedesktop.org/software/systemd/man/systemd.service.html#Options
341 | #
342 | # The options below "RestartSec=5" are mostly security/sandbox related settings
343 | # and limit the exposure of the system towards the unit's processes. You can add
344 | # or remove options as needed of course. For more information see:
345 | # https://www.freedesktop.org/software/systemd/man/systemd.exec.html
346 | k8s_ctl_service_options:
347 | - User={{ k8s_run_as_user }}
348 | - Group={{ k8s_run_as_group }}
349 | - Restart=on-failure
350 | - RestartSec=5
351 | - NoNewPrivileges=true
352 | - ProtectHome=true
353 | - PrivateTmp=true
354 | - PrivateUsers=true
355 | - ProtectSystem=full
356 | - ProtectClock=true
357 | - ProtectKernelModules=true
358 | - ProtectKernelTunables=true
359 | - ProtectKernelLogs=true
360 | - ProtectControlGroups=true
361 | - ProtectHostname=true
362 | - ProtectControlGroups=true
363 | - RestrictNamespaces=true
364 | - RestrictRealtime=true
365 | - RestrictSUIDSGID=true
366 | - CapabilityBoundingSet=~CAP_SYS_PTRACE
367 | - CapabilityBoundingSet=~CAP_KILL
368 | - CapabilityBoundingSet=~CAP_MKNOD
369 | - CapabilityBoundingSet=~CAP_SYS_CHROOT
370 | - CapabilityBoundingSet=~CAP_SYS_ADMIN
371 | - CapabilityBoundingSet=~CAP_SETUID
372 | - CapabilityBoundingSet=~CAP_SETGID
373 | - CapabilityBoundingSet=~CAP_SETPCAP
374 | - CapabilityBoundingSet=~CAP_CHOWN
375 | - SystemCallFilter=@system-service
376 | - ReadWritePaths=-/usr/libexec/kubernetes
377 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ansible-role-kubernetes-controller
2 |
3 | This role is used in [Kubernetes the not so hard way with Ansible - Control plane](https://www.tauceti.blog/post/kubernetes-the-not-so-hard-way-with-ansible-control-plane/). It installs the Kubernetes API server, scheduler and controller manager. For more information about this role please have a look at [Kubernetes the not so hard way with Ansible - Control plane](https://www.tauceti.blog/post/kubernetes-the-not-so-hard-way-with-ansible-control-plane/).
4 |
5 | ## Versions
6 |
7 | I tag every release and try to stay with [semantic versioning](http://semver.org). If you want to use the role I recommend to checkout the latest tag. The master branch is basically development while the tags mark stable releases. But in general I try to keep master in good shape too. A tag `28.0.0+1.33.6` means this is release `28.0.0` of this role and it's meant to be used with Kubernetes version `1.33.6` (but should work with any K8s 1.33.x release of course). If the role itself changes `X.Y.Z` before `+` will increase. If the Kubernetes version changes `X.Y.Z` after `+` will increase too. This allows to tag bugfixes and new major versions of the role while it's still developed for a specific Kubernetes release. That's especially useful for Kubernetes major releases with breaking changes.
8 |
9 | ## Requirements
10 |
11 | This role requires that you already created some certificates for Kubernetes API server (see [Kubernetes the not so hard way with Ansible - Certificate authority (CA)](https://www.tauceti.blog/post/kubernetes-the-not-so-hard-way-with-ansible-certificate-authority/)). The role copies the certificates from `k8s_ctl_ca_conf_directory` (which is by default the same as `k8s_ca_conf_directory` used by `githubixx.kubernetes_ca` role) to the destination host.
12 |
13 | Your hosts on which you want to install Kubernetes should be able to communicate with each other of course. To add an additional layer of security you can setup a fully meshed VPN with WireGuard e.g. (see [Kubernetes the not so hard way with Ansible - WireGuard](https://www.tauceti.blog/post/kubernetes-the-not-so-hard-way-with-ansible-wireguard/)). This encrypts every communication between the Kubernetes nodes if the Kubernetes processes use the WireGuard interface. Using WireGuard actually makes it also easily possible to have a Kubernetes cluster that is distributed in various data centers e.g.
14 |
15 | And of course an [etcd](https://etcd.io/) cluster (see [Kubernetes the not so hard way with Ansible - etcd cluster](https://www.tauceti.blog/post/kubernetes-the-not-so-hard-way-with-ansible-etcd/)) to store the state of the Kubernetes cluster.
16 |
17 | ## Supported OS
18 |
19 | - Ubuntu 22.04 (Jammy Jellyfish)
20 | - Ubuntu 24.04 (Noble Numbat) (recommended)
21 |
22 | ## Changelog
23 |
24 | **Change history:**
25 |
26 | See full [CHANGELOG.md](https://github.com/githubixx/ansible-role-kubernetes-controller/blob/master/CHANGELOG.md)
27 |
28 | **Recent changes:**
29 |
30 | ## 28.0.0+1.33.6
31 |
32 | - **UPDATE**
33 | - update `k8s_ctl_release` to `1.33.6`
34 |
35 | ## 27.1.1+1.32.9
36 |
37 | - **UPDATE**
38 | - update `README.md`
39 |
40 | ## 27.1.0+1.32.9
41 |
42 | - **UPDATE**
43 | - update `k8s_ctl_release` to `1.32.9`
44 |
45 | - **OTHER CHANGES**
46 | - fix for Ansible 2.19 in `kube-apiserver.service.j2`: remove `cluster_hosts()` macro and adjust `combine k8s_apiserver_settings and k8s_apiserver_settings_user` task accordingly
47 | - `defaults/main.yml`: `k8s_ctl_api_endpoint_host`/`k8s_admin_api_endpoint_host` - simplify the complex default variables for endpoint hosts to avoid nested template construction
48 |
49 | - **MOLECULE**
50 | - install `python3-kubernetes` package instead `kubernetes` Pip in `prepare.yml`
51 |
52 | ## 27.0.0+1.32.8
53 |
54 | - **BREAKING**
55 | - Removed Ubuntu 20.04 because reached end of life
56 | - Introduce `k8s_apiserver_admission_plugins` variable. Previously in `k8s_apiserver_settings` variable the values of `enable-admission-plugins` key was a string with list of admission plugins separated by commas. To make that string more readable `k8s_apiserver_admission_plugins` variable was introduced which is now a list of admissions plugins that is consumed by `enable-admission-plugins`. If you didn't changed `k8s_apiserver_admission_plugins` variable or used your own settings nothing changed for you.
57 |
58 | - **UPDATE**
59 | - update `k8s_ctl_release` to `1.32.8`
60 |
61 | - **MOLECULE**
62 | - Removed Ubuntu 20.04 because reached end of life
63 | - Fix `ansible-lint` issues
64 |
65 | ## Installation
66 |
67 | - Directly download from Github (Change into Ansible roles directory before cloning. You can figure out the role path by using `ansible-config dump | grep DEFAULT_ROLES_PATH` command):
68 | `git clone https://github.com/githubixx/ansible-role-kubernetes-controller.git githubixx.kubernetes_controller`
69 |
70 | - Via `ansible-galaxy` command and download directly from Ansible Galaxy:
71 | `ansible-galaxy install role githubixx.kubernetes_controller`
72 |
73 | - Create a `requirements.yml` file with the following content (this will download the role from Github) and install with
74 | `ansible-galaxy role install -r requirements.yml` (change `version` if needed):
75 |
76 | ```yaml
77 | ---
78 | roles:
79 | - name: githubixx.kubernetes_controller
80 | src: https://github.com/githubixx/ansible-role-kubernetes-controller.git
81 | version: 28.0.0+1.33.6
82 | ```
83 |
84 | ## Role (default) variables
85 |
86 | ```yaml
87 | # The base directory for Kubernetes configuration and certificate files for
88 | # everything control plane related. After the playbook is done this directory
89 | # contains various sub-folders.
90 | k8s_ctl_conf_dir: "/etc/kubernetes/controller"
91 |
92 | # All certificate files (Private Key Infrastructure related) specified in
93 | # "k8s_ctl_certificates" and "k8s_ctl_etcd_certificates" (see "vars/main.yml")
94 | # will be stored here. Owner of this new directory will be "root". Group will
95 | # be the group specified in "k8s_run_as_group"`. The files in this directory
96 | # will be owned by "root" and group as specified in "k8s_run_as_group"`. File
97 | # permissions will be "0640".
98 | k8s_ctl_pki_dir: "{{ k8s_ctl_conf_dir }}/pki"
99 |
100 | # The directory to store the Kubernetes binaries (see "k8s_ctl_binaries"
101 | # variable in "vars/main.yml"). Owner and group of this new directory
102 | # will be "root" in both cases. Permissions for this directory will be "0755".
103 | #
104 | # NOTE: The default directory "/usr/local/bin" normally already exists on every
105 | # Linux installation with the owner, group and permissions mentioned above. If
106 | # your current settings are different consider a different directory. But make sure
107 | # that the new directory is included in your "$PATH" variable value.
108 | k8s_ctl_bin_dir: "/usr/local/bin"
109 |
110 | # The Kubernetes release.
111 | k8s_ctl_release: "1.33.6"
112 |
113 | # The interface on which the Kubernetes services should listen on. As all cluster
114 | # communication should use a VPN interface the interface name is
115 | # normally "wg0" (WireGuard),"peervpn0" (PeerVPN) or "tap0".
116 | #
117 | # The network interface on which the Kubernetes control plane services should
118 | # listen on. That is:
119 | #
120 | # - kube-apiserver
121 | # - kube-scheduler
122 | # - kube-controller-manager
123 | #
124 | k8s_interface: "eth0"
125 |
126 | # Run Kubernetes control plane service (kube-apiserver, kube-scheduler,
127 | # kube-controller-manager) as this user.
128 | #
129 | # If you want to use a "secure-port" < 1024 for "kube-apiserver" you most
130 | # probably need to run "kube-apiserver" as user "root" (not recommended).
131 | #
132 | # If the user specified in "k8s_run_as_user" does not exist then the role
133 | # will create it. Only if the user already exists the role will not create it
134 | # but it will adjust it's UID/GID and shell if specified (see settings below).
135 | # So make sure that UID, GID and shell matches the existing user if you don't
136 | # want that that user will be changed.
137 | #
138 | # Additionally if "k8s_run_as_user" is "root" then this role wont touch the user
139 | # at all.
140 | k8s_run_as_user: "k8s"
141 |
142 | # UID of user specified in "k8s_run_as_user". If not specified the next available
143 | # UID from "/etc/login.defs" will be taken (see "SYS_UID_MAX" setting in that file).
144 | # k8s_run_as_user_uid: "999"
145 |
146 | # Shell for specified user in "k8s_run_as_user". For increased security keep
147 | # the default.
148 | k8s_run_as_user_shell: "/bin/false"
149 |
150 | # Specifies if the user specified in "k8s_run_as_user" will be a system user (default)
151 | # or not. If "true" the "k8s_run_as_user_home" setting will be ignored. In general
152 | # it makes sense to keep the default as there should be no need to login as
153 | # the user that runs kube-apiserver, kube-scheduler or kube-controller-manager.
154 | k8s_run_as_user_system: true
155 |
156 | # Home directory of user specified in "k8s_run_as_user". Will be ignored if
157 | # "k8s_run_as_user_system" is set to "true". In this case no home directory will
158 | # be created. Normally not needed.
159 | # k8s_run_as_user_home: "/home/k8s"
160 |
161 | # Run Kubernetes daemons (kube-apiserver, kube-scheduler, kube-controller-manager)
162 | # as this group.
163 | #
164 | # Note: If the group specified in "k8s_run_as_group" does not exist then the role
165 | # will create it. Only if the group already exists the role will not create it
166 | # but will adjust GID if specified in "k8s_run_as_group_gid" (see setting below).
167 | k8s_run_as_group: "k8s"
168 |
169 | # GID of group specified in "k8s_run_as_group". If not specified the next available
170 | # GID from "/etc/login.defs" will be take (see "SYS_GID_MAX" setting in that file).
171 | # k8s_run_as_group_gid: "999"
172 |
173 | # Specifies if the group specified in "k8s_run_as_group" will be a system group (default)
174 | # or not.
175 | k8s_run_as_group_system: true
176 |
177 | # By default all tasks that needs to communicate with the Kubernetes
178 | # cluster are executed on local host (127.0.0.1). But if that one
179 | # doesn't have direct connection to the K8s cluster or should be executed
180 | # elsewhere this variable can be changed accordingly.
181 | k8s_ctl_delegate_to: "127.0.0.1"
182 |
183 | # The IP address or hostname of the Kubernetes API endpoint. This variable
184 | # is used by "kube-scheduler" and "kube-controller-manager" to connect
185 | # to the "kube-apiserver" (Kubernetes API server).
186 | #
187 | # By default the first host in the Ansible group "k8s_controller" is
188 | # specified here. NOTE: This setting is not fault tolerant! That means
189 | # if the first host in the Ansible group "k8s_controller" is down
190 | # the worker node and its workload continue working but the worker
191 | # node doesn't receive any updates from Kubernetes API server.
192 | #
193 | # If you have a loadbalancer that distributes traffic between all
194 | # Kubernetes API servers it should be specified here (either its IP
195 | # address or the DNS name). But you need to make sure that the IP
196 | # address or the DNS name you want to use here is included in the
197 | # Kubernetes API server TLS certificate (see "k8s_apiserver_cert_hosts"
198 | # variable of https://github.com/githubixx/ansible-role-kubernetes-ca
199 | # role). If it's not specified you'll get certificate errors in the
200 | # logs of the services mentioned above.
201 | k8s_ctl_api_endpoint_host: "{% set controller_host = groups['k8s_controller'][0] %}{{ hostvars[controller_host]['ansible_' + hostvars[controller_host]['k8s_interface']].ipv4.address }}"
202 |
203 | # As above just for the port. It specifies on which port the
204 | # Kubernetes API servers are listening. Again if there is a loadbalancer
205 | # in place that distributes the requests to the Kubernetes API servers
206 | # put the port of the loadbalancer here.
207 | k8s_ctl_api_endpoint_port: "6443"
208 |
209 | # Normally "kube-apiserver", "kube-controller-manager" and "kube-scheduler" log
210 | # to "journald". But there are exceptions like the audit log. For this kind of
211 | # log files this directory will be used as a base path. The owner and group
212 | # of this directory will be the one specified in "k8s_run_as_user" and "k8s_run_as_group"
213 | # as these services run as this user and need permissions to create log files
214 | # in this directory.
215 | k8s_ctl_log_base_dir: "/var/log/kubernetes"
216 |
217 | # Permissions for directory specified in "k8s_ctl_log_base_dir"
218 | k8s_ctl_log_base_dir_mode: "0770"
219 |
220 | # The port the control plane components should connect to etcd cluster
221 | k8s_ctl_etcd_client_port: "2379"
222 |
223 | # The interface the etcd cluster is listening on
224 | k8s_ctl_etcd_interface: "eth0"
225 |
226 | # The location of the directory where the Kubernetes certificates are stored.
227 | # These certificates were generated by the "kubernetes_ca" Ansible role if you
228 | # haven't used a different method to generate these certificates. So this
229 | # directory is located on the Ansible controller host. That's normally the
230 | # host where "ansible-playbook" gets executed. "k8s_ca_conf_directory" is used
231 | # by the "kubernetes_ca" Ansible role to store the certificates. So it's
232 | # assumed that this variable is already set.
233 | k8s_ctl_ca_conf_directory: "{{ k8s_ca_conf_directory }}"
234 |
235 | # Directory where "admin.kubeconfig" (the credentials file) for the "admin" user
236 | # is stored. By default this directory (and it's "kubeconfig" file) will
237 | # be stored on the host specified in "k8s_ctl_delegate_to". By default this
238 | # is "127.0.0.1". So if you run "ansible-playbook" locally e.g. the directory
239 | # and file will be created there.
240 | #
241 | # By default the value of this variable will expand to the user's local $HOME
242 | # plus "/k8s/certs". That means if the user's $HOME directory is e.g.
243 | # "/home/da_user" then "k8s_admin_conf_dir" will have a value of
244 | # "/home/da_user/k8s/certs".
245 | k8s_admin_conf_dir: "{{ '~/k8s/configs' | expanduser }}"
246 |
247 | # Permissions for the directory specified in "k8s_admin_conf_dir"
248 | k8s_admin_conf_dir_perm: "0700"
249 |
250 | # Owner of the directory specified in "k8s_admin_conf_dir" and for
251 | # "admin.kubeconfig" stored in this directory.
252 | k8s_admin_conf_owner: "root"
253 |
254 | # Group of the directory specified in "k8s_admin_conf_dir" and for
255 | # "admin.kubeconfig" stored in this directory.
256 | k8s_admin_conf_group: "root"
257 |
258 | # Host where the "admin" user connects to administer the K8s cluster.
259 | # This setting is written into "admin.kubeconfig". This allows to use
260 | # a different host/loadbalancer as the K8s services which might use an internal
261 | # loadbalancer while the "admin" user connects to a different host/loadbalancer
262 | # that distributes traffic to the "kube-apiserver" e.g.
263 | #
264 | # Besides that basically the same comments as for "k8s_ctl_api_endpoint_host"
265 | # variable apply.
266 | k8s_admin_api_endpoint_host: "{% set controller_host = groups['k8s_controller'][0] %}{{ hostvars[controller_host]['ansible_' + hostvars[controller_host]['k8s_interface']].ipv4.address }}"
267 |
268 | # As above just for the port.
269 | k8s_admin_api_endpoint_port: "6443"
270 |
271 | # Directory to store "kube-apiserver" audit logs (if enabled). The owner and
272 | # group of this directory will be the one specified in "k8s_run_as_user"
273 | # and "k8s_run_as_group".
274 | k8s_apiserver_audit_log_dir: "{{ k8s_ctl_log_base_dir }}/kube-apiserver"
275 |
276 | # The directory to store "kube-apiserver" configuration.
277 | k8s_apiserver_conf_dir: "{{ k8s_ctl_conf_dir }}/kube-apiserver"
278 |
279 | # "kube-apiserver" daemon settings (can be overridden or additional added by defining
280 | # "k8s_apiserver_settings_user")
281 | k8s_apiserver_settings:
282 | "advertise-address": "{{ hostvars[inventory_hostname]['ansible_' + k8s_interface].ipv4.address }}"
283 | "bind-address": "{{ hostvars[inventory_hostname]['ansible_' + k8s_interface].ipv4.address }}"
284 | "secure-port": "6443"
285 | "enable-admission-plugins": "{{ k8s_apiserver_admission_plugins | join(',') }}"
286 | "allow-privileged": "true"
287 | "authorization-mode": "Node,RBAC"
288 | "audit-log-maxage": "30"
289 | "audit-log-maxbackup": "3"
290 | "audit-log-maxsize": "100"
291 | "audit-log-path": "{{ k8s_apiserver_audit_log_dir }}/audit.log"
292 | "event-ttl": "1h"
293 | "kubelet-preferred-address-types": "InternalIP,Hostname,ExternalIP" # "--kubelet-preferred-address-types" defaults to:
294 | # "Hostname,InternalDNS,InternalIP,ExternalDNS,ExternalIP"
295 | # Needs to be changed to make "kubectl logs" and "kubectl exec" work.
296 | "runtime-config": "api/all=true"
297 | "service-cluster-ip-range": "10.32.0.0/16"
298 | "service-node-port-range": "30000-32767"
299 | "client-ca-file": "{{ k8s_ctl_pki_dir }}/ca-k8s-apiserver.pem"
300 | "etcd-cafile": "{{ k8s_ctl_pki_dir }}/ca-etcd.pem"
301 | "etcd-certfile": "{{ k8s_ctl_pki_dir }}/cert-k8s-apiserver-etcd.pem"
302 | "etcd-keyfile": "{{ k8s_ctl_pki_dir }}/cert-k8s-apiserver-etcd-key.pem"
303 | "encryption-provider-config": "{{ k8s_apiserver_conf_dir }}/encryption-config.yaml"
304 | "encryption-provider-config-automatic-reload": "true"
305 | "kubelet-certificate-authority": "{{ k8s_ctl_pki_dir }}/ca-k8s-apiserver.pem"
306 | "kubelet-client-certificate": "{{ k8s_ctl_pki_dir }}/cert-k8s-apiserver.pem"
307 | "kubelet-client-key": "{{ k8s_ctl_pki_dir }}/cert-k8s-apiserver-key.pem"
308 | "service-account-key-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-controller-manager-sa.pem"
309 | "service-account-signing-key-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-controller-manager-sa-key.pem"
310 | "service-account-issuer": "https://{{ groups.k8s_controller | first }}:6443"
311 | "tls-cert-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-apiserver.pem"
312 | "tls-private-key-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-apiserver-key.pem"
313 |
314 | # kube-apiserver admission plugins used in "k8s_apiserver_settings" variable
315 | # for "enable-admission-plugins" key.
316 | k8s_apiserver_admission_plugins:
317 | - NodeRestriction
318 | - NamespaceLifecycle
319 | - LimitRanger
320 | - ServiceAccount
321 | - TaintNodesByCondition
322 | - Priority
323 | - DefaultTolerationSeconds
324 | - DefaultStorageClass
325 | - PersistentVolumeClaimResize
326 | - MutatingAdmissionWebhook
327 | - ValidatingAdmissionWebhook
328 | - ResourceQuota
329 | - PodSecurity
330 | - StorageObjectInUseProtection
331 | - RuntimeClass
332 | - CertificateApproval
333 | - CertificateSigning
334 | - ClusterTrustBundleAttest
335 | - CertificateSubjectRestriction
336 | - DefaultIngressClass
337 |
338 | # This is the content of "encryption-config.yaml". Used by "kube-apiserver"
339 | # (see "encryption-provider-config" option in "k8s_apiserver_settings").
340 | # "kube-apiserver" will use this configuration to encrypt data before storing
341 | # it in etcd (encrypt data at-rest).
342 | #
343 | # The configuration below is a usable example but might not fit your needs.
344 | # So please review carefully! E.g. you might want to replace "aescbc" provider
345 | # with a different one like "secretbox". As you can see this configuration only
346 | # encrypts "secrets" at-rest. But it's also possible to encrypt other K8s
347 | # resources. NOTE: "identity" provider doesn't encrypt anything! That means
348 | # plain text. In the configuration below it's used as fallback.
349 | #
350 | # If you keep the default defined below please make sure to specify the
351 | # variable "k8s_encryption_config_key" somewhere (e.g. "group_vars/all.yml" or
352 | # even better use "ansible-vault" to store these kind of secrets).
353 | # This needs to be a base64 encoded value. To create such a value on Linux
354 | # run the following command:
355 | #
356 | # head -c 32 /dev/urandom | base64
357 | #
358 | # For a detailed description please visit:
359 | # https://kubernetes.io/docs/tasks/administer-cluster/encrypt-data/
360 | #
361 | # How to rotate the encryption key or to implement encryption at-rest in
362 | # an existing K8s cluster please visit:
363 | # https://kubernetes.io/docs/tasks/administer-cluster/encrypt-data/#rotating-a-decryption-key
364 | k8s_apiserver_encryption_provider_config: |
365 | ---
366 | kind: EncryptionConfiguration
367 | apiVersion: apiserver.config.k8s.io/v1
368 | resources:
369 | - resources:
370 | - secrets
371 | providers:
372 | - aescbc:
373 | keys:
374 | - name: key1
375 | secret: {{ k8s_encryption_config_key }}
376 | - identity: {}
377 |
378 | # The directory to store controller manager configuration.
379 | k8s_controller_manager_conf_dir: "{{ k8s_ctl_conf_dir }}/kube-controller-manager"
380 |
381 | # K8s controller manager settings (can be overridden or additional added by defining
382 | # "k8s_controller_manager_settings_user")
383 | k8s_controller_manager_settings:
384 | "bind-address": "{{ hostvars[inventory_hostname]['ansible_' + k8s_interface].ipv4.address }}"
385 | "secure-port": "10257"
386 | "cluster-cidr": "10.200.0.0/16"
387 | "allocate-node-cidrs": "true"
388 | "cluster-name": "kubernetes"
389 | "authentication-kubeconfig": "{{ k8s_controller_manager_conf_dir }}/kubeconfig"
390 | "authorization-kubeconfig": "{{ k8s_controller_manager_conf_dir }}/kubeconfig"
391 | "kubeconfig": "{{ k8s_controller_manager_conf_dir }}/kubeconfig"
392 | "leader-elect": "true"
393 | "service-cluster-ip-range": "10.32.0.0/16"
394 | "cluster-signing-cert-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-apiserver.pem"
395 | "cluster-signing-key-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-apiserver-key.pem"
396 | "root-ca-file": "{{ k8s_ctl_pki_dir }}/ca-k8s-apiserver.pem"
397 | "requestheader-client-ca-file": "{{ k8s_ctl_pki_dir }}/ca-k8s-apiserver.pem"
398 | "service-account-private-key-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-controller-manager-sa-key.pem"
399 | "use-service-account-credentials": "true"
400 | "client-ca-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-apiserver.pem"
401 | "tls-cert-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-controller-manager.pem"
402 | "tls-private-key-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-controller-manager-key.pem"
403 |
404 | # The directory to store scheduler configuration.
405 | k8s_scheduler_conf_dir: "{{ k8s_ctl_conf_dir }}/kube-scheduler"
406 |
407 | # kube-scheduler settings
408 | k8s_scheduler_settings:
409 | "bind-address": "{{ hostvars[inventory_hostname]['ansible_' + k8s_interface].ipv4.address }}"
410 | "config": "{{ k8s_scheduler_conf_dir }}/kube-scheduler.yaml"
411 | "authentication-kubeconfig": "{{ k8s_scheduler_conf_dir }}/kubeconfig"
412 | "authorization-kubeconfig": "{{ k8s_scheduler_conf_dir }}/kubeconfig"
413 | "requestheader-client-ca-file": "{{ k8s_ctl_pki_dir }}/ca-k8s-apiserver.pem"
414 | "client-ca-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-apiserver.pem"
415 | "tls-cert-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-scheduler.pem"
416 | "tls-private-key-file": "{{ k8s_ctl_pki_dir }}/cert-k8s-scheduler-key.pem"
417 |
418 | # These sandbox security/sandbox related settings will be used for
419 | # "kube-apiserver", "kube-scheduler" and "kube-controller-manager"
420 | # systemd units. These options will be placed in the "[Service]" section.
421 | # The default settings should be just fine for increased security of the
422 | # mentioned services. So it makes sense to keep them if possible.
423 | #
424 | # For more information see:
425 | # https://www.freedesktop.org/software/systemd/man/systemd.service.html#Options
426 | #
427 | # The options below "RestartSec=5" are mostly security/sandbox related settings
428 | # and limit the exposure of the system towards the unit's processes. You can add
429 | # or remove options as needed of course. For more information see:
430 | # https://www.freedesktop.org/software/systemd/man/systemd.exec.html
431 | k8s_ctl_service_options:
432 | - User={{ k8s_run_as_user }}
433 | - Group={{ k8s_run_as_group }}
434 | - Restart=on-failure
435 | - RestartSec=5
436 | - NoNewPrivileges=true
437 | - ProtectHome=true
438 | - PrivateTmp=true
439 | - PrivateUsers=true
440 | - ProtectSystem=full
441 | - ProtectClock=true
442 | - ProtectKernelModules=true
443 | - ProtectKernelTunables=true
444 | - ProtectKernelLogs=true
445 | - ProtectControlGroups=true
446 | - ProtectHostname=true
447 | - ProtectControlGroups=true
448 | - RestrictNamespaces=true
449 | - RestrictRealtime=true
450 | - RestrictSUIDSGID=true
451 | - CapabilityBoundingSet=~CAP_SYS_PTRACE
452 | - CapabilityBoundingSet=~CAP_KILL
453 | - CapabilityBoundingSet=~CAP_MKNOD
454 | - CapabilityBoundingSet=~CAP_SYS_CHROOT
455 | - CapabilityBoundingSet=~CAP_SYS_ADMIN
456 | - CapabilityBoundingSet=~CAP_SETUID
457 | - CapabilityBoundingSet=~CAP_SETGID
458 | - CapabilityBoundingSet=~CAP_SETPCAP
459 | - CapabilityBoundingSet=~CAP_CHOWN
460 | - SystemCallFilter=@system-service
461 | - ReadWritePaths=-/usr/libexec/kubernetes
462 | ```
463 |
464 | The kube-apiserver settings defined in `k8s_apiserver_settings` can be overridden by defining a variable called `k8s_apiserver_settings_user`. You can also add additional settings by using this variable. E.g. to override `audit-log-maxage` and `audit-log-maxbackup` default values and add `watch-cache` add the following settings to `group_vars/k8s.yml`:
465 |
466 | ```yaml
467 | k8s_apiserver_settings_user:
468 | "audit-log-maxage": "40"
469 | "audit-log-maxbackup": "4"
470 | "watch-cache": "false"
471 | ```
472 |
473 | The same is true for the `kube-controller-manager` by adding entries to `k8s_controller_manager_settings_user` variable. For `kube-scheduler` add entries to `k8s_scheduler_settings_user` variable to override/add settings in `k8s_scheduler_settings` dictionary.
474 |
475 | ## Example Playbook
476 |
477 | ```yaml
478 | - hosts: k8s_controller
479 | roles:
480 | - githubixx.kubernetes_controller
481 | ```
482 |
483 | ## Testing
484 |
485 | This role has a small test setup that is created using [Molecule](https://github.com/ansible-community/molecule), libvirt (vagrant-libvirt) and QEMU/KVM. Please see my blog post [Testing Ansible roles with Molecule, libvirt (vagrant-libvirt) and QEMU/KVM](https://www.tauceti.blog/posts/testing-ansible-roles-with-molecule-libvirt-vagrant-qemu-kvm/) how to setup. The Molecule test configuration is in [molecule/default](https://github.com/githubixx/ansible-role-kubernetes-controller/tree/master/molecule/default).
486 |
487 | Afterwards Molecule can be executed:
488 |
489 | ```bash
490 | molecule converge
491 | ```
492 |
493 | This will setup a few virtual machines (VM) with supported Ubuntu OS and installs an Kubernetes cluster but without the worker nodes (so no nodes with `kube-proxy` and `kubelet` installed). A small verification step is also included:
494 |
495 | ```bash
496 | molecule verify
497 | ```
498 |
499 | To clean up run
500 |
501 | ```bash
502 | molecule destroy
503 | ```
504 |
505 | ## License
506 |
507 | GNU GENERAL PUBLIC LICENSE Version 3
508 |
509 | ## Author Information
510 |
511 | [http://www.tauceti.blog](http://www.tauceti.blog)
512 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## 28.0.0+1.33.6
4 |
5 | - **UPDATE**
6 | - update `k8s_ctl_release` to `1.33.6`
7 | - `meta/main.yml`: set `min_ansible_version` to `2.15`
8 |
9 | - **MOLECULE**
10 | - replace Ubuntu 20.04 with 24.04
11 |
12 | ## 27.1.1+1.32.9
13 |
14 | - **UPDATE**
15 | - update `README.md'
16 |
17 | ## 27.1.0+1.32.9
18 |
19 | - **UPDATE**
20 | - update `k8s_ctl_release` to `1.32.9`
21 |
22 | - **OTHER CHANGES**
23 | - fix for Ansible 2.19 in `kube-apiserver.service.j2`: remove `cluster_hosts()` macro and adjust `combine k8s_apiserver_settings and k8s_apiserver_settings_user` task accordingly
24 | - `defaults/main.yml`: `k8s_ctl_api_endpoint_host`/`k8s_admin_api_endpoint_host` - simplify the complex default variables for endpoint hosts to avoid nested template construction
25 |
26 | - **MOLECULE**
27 | - install `python3-kubernetes` package instead `kubernetes` Pip in `prepare.yml`
28 |
29 | ## 27.0.0+1.32.8
30 |
31 | - **BREAKING**
32 | - Removed Ubuntu 20.04 because reached end of life
33 | - Introduce `k8s_apiserver_admission_plugins` variable. Previously in `k8s_apiserver_settings` variable the values of `enable-admission-plugins` key was a string with list of admission plugins separated by commas. To make that string more readable `k8s_apiserver_admission_plugins` variable was introduced which is now a list of admissions plugins that is consumed by `enable-admission-plugins`. If you didn't changed `k8s_apiserver_admission_plugins` variable or used your own settings nothing changed for you.
34 |
35 | - **UPDATE**
36 | - update `k8s_ctl_release` to `1.32.8`
37 |
38 | - **MOLECULE**
39 | - Removed Ubuntu 20.04 because reached end of life
40 | - Fix `ansible-lint` issues
41 |
42 | ## 26.0.2+1.31.11
43 |
44 | - **UPDATE**
45 | - update `k8s_ctl_release` to `1.31.11`
46 |
47 | ## 26.0.1+1.31.5
48 |
49 | - **OTHER CHANGES**
50 | - add flags `client-ca-file`, `tls-cert-file` and `tls-private-key-file` to `k8s_controller_manager_settings` (contribution by @hajowieland). Fixes [#69](https://github.com/githubixx/ansible-role-kubernetes-controller/issues/69)
51 | - add flags `client-ca-file`, `tls-cert-file` and `tls-private-key-file` to `k8s_scheduler_settings`
52 |
53 | ## 26.0.0+1.31.5
54 |
55 | - **UPDATE**
56 | - update `k8s_ctl_release` to `1.31.5`
57 |
58 | ## 25.0.1+1.30.9
59 |
60 | - **UPDATE**
61 | - update `k8s_ctl_release` to `1.30.9`
62 |
63 | - **OTHER CHANGES**
64 | - update `.gitignore`
65 | - fix `ansible-lint` issues
66 |
67 | ## 25.0.0+1.30.5
68 |
69 | - **UPDATE**
70 | - update `k8s_ctl_release` to `1.30.5`
71 |
72 | - **OTHER CHANGES**
73 | - support Ubuntu 24.04
74 | - update `.yamllint`
75 |
76 | ## 24.0.2+1.29.9
77 |
78 | - **OTHER CHANGES**
79 | - fix download URLs for Kubernetes binaries (see: [Download Kubernetes - Binaries](https://kubernetes.io/releases/download/#binaries)
80 |
81 | ## 24.0.1+1.29.9
82 |
83 | - **UPDATE**
84 | - update `k8s_ctl_release` to `1.29.9`
85 |
86 | ## 24.0.0+1.29.4
87 |
88 | - **UPDATE**
89 | - update `k8s_ctl_release` to `1.29.4`
90 |
91 | ## 24.0.0+1.29.3
92 |
93 | - **UPDATE**
94 | - update `k8s_ctl_release` to `1.29.3`
95 | - Molecule: use `alvistack` instead of `generic` Vagrant boxes
96 |
97 | ## 23.1.2+1.28.8
98 |
99 | - **UPDATE**
100 | - update `k8s_ctl_release` to `1.28.8`
101 |
102 | ## 23.1.1+1.28.5
103 |
104 | - **BUGFIX**
105 | - ClusterRoleBinding `system:kube-apiserver` needs to honor `k8s_apiserver_csr_cn` value for as username
106 | - Because of the previous change move `files/kube-apiserver-to-kubelet_cluster_role.yaml -> templates/rbac/kube-apiserver-to-kubelet_cluster_role.yaml.j2` and `files/kube-apiserver-to-kubelet_cluster_role_binding.yaml -> templates/rbac/kube-apiserver-to-kubelet_cluster_role_binding.yaml.j2` as both files became a Jinja2 template.
107 |
108 | ## 23.1.0+1.28.5
109 |
110 | - **MOLECULE**
111 | - Change to Ubuntu 22.04 for test-assets VM
112 | - Adjust common names for certificates / change algo to ecdsa and algo size
113 |
114 | - **OTHER CHANGES**
115 | - Fix permissions for temporary directory
116 | - Adjust Github action because of Ansible Galaxy changes
117 |
118 | ## 23.0.0+1.28.5
119 |
120 | - **UPDATE**
121 | - Update `k8s_ctl_release` to `1.28.5`
122 |
123 | - **BREAKING**
124 | - Extend `enable-admission-plugins` in `k8s_apiserver_settings` by: `PodSecurity,Priority,StorageObjectInUseProtection,RuntimeClass,CertificateApproval,CertificateSigning,ClusterTrustBundleAttest,CertificateSubjectRestriction,DefaultIngressClass`. These are enabled by default if this flag is not specified (see [Admission Controllers Reference](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/) for more information).
125 |
126 | - **MOLECULE**
127 | - Change IP addresses
128 |
129 | ## 22.0.0+1.27.8
130 |
131 | - **PLEASE READ CAREFULLY**
132 | This release contains quite a few potential breaking changes! So review carefully before rolling out the new version of this role! A bigger part of the whole changes are related to increase security. While most of the new variables and defaults should be just fine and should just work out of the box side effects might occur.
133 |
134 | All the newly introduced or changed variables have detailed comments in [README](https://github.com/githubixx/ansible-role-kubernetes-controller/blob/master/README.md). So please read them carefully!
135 |
136 | This refactoring was needed to make it possible to have `githubixx.kubernetes_controller` and `githubixx.kubernetes_worker` deployed on the same host e.g. They were some intersections between the two roles that had to be fixed.
137 |
138 | **Please remove** `/var/lib/kubernetes/admin.kubeconfig` on the K8s controller nodes (if you didn't change the default directory for this file). Older versions of this role created this file. It's no longer needed. It contains the `kubeconfig` (so basically the credentials file) for the `admin` user. This is a very powerful user (actually the user with the most permissions). So use with care and store the file in a secure place! `admin.kubeconfig` should only be used at the very beginning to create a new user with less permissions.
139 |
140 | - **UPDATE**
141 | - update `k8s_ctl_release` to `1.27.8`
142 |
143 | - **BREAKING**
144 | - Rename variable `k8s_conf_dir` to `k8s_ctl_conf_dir`. Additionally the default value changed from `/usr/lib/kubernetes` to `/etc/kubernetes/controller`.
145 | - Introduce variable `k8s_admin_conf_dir`. Currently it only stores `admin.kubeconfig` which is basically the credentials file of the `admin` "user". Formerly this file was stored in the directory specified in the (now removed) `k8s_config_directory` variable. The default value of `k8s_admin_conf_dir` is the same as the removed `k8s_config_directory`. Additionally to set permissions for `k8s_admin_conf_dir` the following variables were introduced: `k8s_admin_conf_dir_perm`, `k8s_admin_conf_owner` and `k8s_admin_conf_group`.
146 | - Introduce variable `k8s_ctl_pki_dir`. All certificate files specified in `k8s_ctl_certificates` and `k8s_ctl_etcd_certificates` (see `vars/main.yml`) will be stored here. Related to this: Certificate related settings in `k8s_apiserver_settings` used `k8s_conf_dir` before and now use `k8s_ctl_pki_dir`. That's `client-ca-file`, `etcd-cafile`, `etcd-certfile`, `etcd-keyfile`, `kubelet-certificate-authority`, `kubelet-client-certificate`, `kubelet-client-key`, `service-account-key-file`, `service-account-signing-key-file`, `tls-cert-file` and `tls-private-key-file`. For `k8s_controller_manager_settings` that's: `cluster-signing-cert-file`, `cluster-signing-key-file`, `root-ca-file`, `requestheader-client-ca-file` and `service-account-private-key-file`. And for `k8s_scheduler_settings` that's: `requestheader-client-ca-file`.
147 | - Rename variable `k8s_bin_dir` to `k8s_ctl_bin_dir`.
148 | - Rename variable `k8s_release` to `k8s_ctl_release`.
149 | - The default value for `k8s_interface` changed from `tap0` to `eth0`.
150 | - Rename variable `k8s_controller_binaries` to `k8s_ctl_binaries`. Additionally this variable is no longer defined in `defaults/main.yml` but in `vars/main.yml`. Since this list is fixed anyways it makes no sense to allow to modify this list.
151 | - Rename variable `k8s_certificates` to `k8s_ctl_certificates`.
152 | - Rename variable `etcd_certificates` to `k8s_ctl_etcd_certificates`. Additionally this variable is no longer defined in `defaults/main.yml` but in `vars/main.yml`. Since this list is fixed anyways it makes no sense to allow to modify this list.
153 | - Rename variable `etcd_client_port` to `k8s_ctl_etcd_client_port`.
154 | - Rename variable `etcd_interface` to `k8s_ctl_etcd_interface`. Additionally the default value changed from `tap0` to `eth0`.
155 | - Use `k8s_ctl_etcd_interface` variable instead of `k8s_interface` for `--etcd-servers` option in `templates/etc/systemd/system/kube-apiserver.service.j2`. Normally `etcd` and `kube-apiserver` listen on the same interface. But if someone specified `k8s_ctl_etcd_interface` (formerly `etcd_interface` in the context of this role) it was basically ignored as the value of `k8s_interface` was used instead. That's fixed now.
156 | - Rename variable `k8s_controller_delegate_to` to `k8s_ctl_delegate_to`.
157 | - Introduce `k8s_apiserver_conf_dir` variable. `encryption-config.yaml` is now located in `k8s_apiserver_conf_dir`.
158 | - Change default value of `k8s_controller_manager_conf_dir` to `"{{ k8s_ctl_conf_dir }}/kube-controller-manager"`.
159 | - Change default value of `k8s_scheduler_conf_dir` to `"{{ k8s_ctl_conf_dir }}/kube-scheduler"`.
160 | - Rename `kube-controller-manager.kubeconfig` to `kubeconfig`. This affects `k8s_controller_manager_settings` and the following settings: `authentication-kubeconfig`, `authorization-kubeconfig` and `kubeconfig`.
161 | - Rename `kube-scheduler.kubeconfig` to `kubeconfig`. This affects `k8s_scheduler_settings` and the following settings: `authentication-kubeconfig"` and `authorization-kubeconfig`.
162 | - Added new option `encryption-provider-config-automatic-reload: "true"` to `k8s_apiserver_settings`. In case the file specified in `encryption-provider-config` changes `kube-apiserver` will automatically reload that file. This is handy if one wants to change the encryption provider (also see new variable `k8s_apiserver_encryption_provider_config`)
163 | - Introduce `k8s_ctl_service_options` variable. As mentioned above already previously `kube-apiserver`, `kube-controller-manager` and `kube-scheduler` were running as user `root`. Now these services will run as `k8s_run_as_user` and `k8s_run_as_group`. Additionally `systemd` allows to limit the exposure of the system towards the unit's processes. Basically all settings below `RestartSec=5` are related to increase security and limit what the process allowed to do. So these settings reduce the attack surface quite a bit already. They're not perfect but a starting point. If you want the previous behavior just remove all settings besides `Restart` and `RestartSec`. But that also means that they'll run again as `root` user.
164 | - The following variables are no longer used and can be removed: `k8s_encryption_config_directory`, `k8s_encryption_config_owner`, `k8s_encryption_config_group`, `k8s_encryption_config_directory_perm` and `k8s_encryption_config_file_perm`. Previously these values were needed to specify permissions on the Ansible controller for this file/directory. Since this file is now generated directly on the K8s controller nodes they're no longer needed. That also means you can remove `encryption-config.yaml` from Ansible controller node (like your workstation e.g.)
165 | - The variable `k8s_config_directory` is gone. It's no longer in use. After the upgrade to this release you can delete this directory (if you accept the new default!) and it's content (make a backup esp. of `admin.kubeconfig` file - just in case!)
166 | - Rename `k8s_ca_conf_directory` to `k8s_ctl_ca_conf_directory`
167 |
168 | - **FEATURE**
169 | - Introduce `k8s_run_as_user` variable. Previously all control plane services like `kube-apiserver`, `kube-scheduler` and `kube-controller-manager` run as user `root`. Security-wise that's not optimal. There is just no need to run them as `root` as long they use a listening port > `1024` which they do by default. In this version all these services will run as the user specified with `k8s_run_as_user` which is `k8s` by default. Related to this variable are the new variables `k8s_run_as_user_shell`, `k8s_run_as_user_system`, `k8s_run_as_group` and `k8s_run_as_group_system`. See [README](https://github.com/githubixx/ansible-role-kubernetes-controller/blob/master/README.md) for further information about this variables. The defaults should be just fine even for upgrading from a previous version of this role.
170 | - Introduce `k8s_ctl_api_endpoint_host` and `k8s_ctl_api_endpoint_port` variables. Previously `kube-scheduler` and `kube-controller-manager` where configured to connect to the first host in the Ansible `k8s_controller` group and communicate with the `kube-apiserver` that was running there. This was hard-coded and couldn't be changed. If that host was down the K8s worker nodes didn't receive any updates. Now one can install and use a load balancer like `haproxy` e.g. that distributes requests between all `kube-apiserver`'s and takes a `kube-apiserver` out of rotation if that one is down (also see my Ansible [haproxy role](https://github.com/githubixx/ansible-role-haproxy) for that use case). The default is still to use the first host/kube-apiserver in the Ansible `k8s_controller` group. So behavior-wise nothing changed basically.
171 | - Introduce `k8s_admin_api_endpoint_host` and `k8s_admin_api_endpoint_port` variables. For these two variables the same is basically true as for `k8s_ctl_api_endpoint_host` and `k8s_ctl_api_endpoint_port` variables above. But these settings are meant to be used by the `admin` user that this role creates by default. These settings are written into `admin.kubeconfig`. So it's possible to configure another host/load balancer for the `admin` user as for the K8s control plane services mentioned in the previous paragraph.
172 | - Introduce `k8s_ctl_log_base_dir` and `k8s_ctl_log_base_dir_mode`. Normally `kube-apiserver`, `kube-controller-manager` and `kube-scheduler` log to `journald`. But there are exceptions like the audit log. For this kind of log files this directory will be used as a base path.
173 | - Introduce `k8s_apiserver_audit_log_dir`. Directory to store kube-apiserver audit logs.
174 | - Introduce `k8s_apiserver_encryption_provider_config` variable. Previously the content of this file was hard-coded. Now it's exposed via this variable. The content of that variable and the previously hard-coded value are the same. So if you keep the default when upgrading everything stays the same in that regards. **NOTE**: Changing this configuration and deploy the changes can potentially cause quite some problems! Make sure to read [Encrypting Confidential Data at Rest](https://kubernetes.io/docs/tasks/administer-cluster/encrypt-data/) and esp. [Rotating a decryption key](https://kubernetes.io/docs/tasks/administer-cluster/encrypt-data/#rotating-a-decryption-key)!
175 | - Add task to generate `kubeconfig` for `admin` user (previously this was a separate [playbook](https://github.com/githubixx/ansible-kubernetes-playbooks/tree/v15.0.0_r1.27.5/kubeauthconfig)).
176 | - Add task to generate `kubeconfig` for `kube-controller-manager` service (previously this was a separate [playbook](https://github.com/githubixx/ansible-kubernetes-playbooks/tree/v15.0.0_r1.27.5/kubeauthconfig)).
177 | - Add task to generate `kubeconfig` for `kube-scheduler` service (previously this was a separate [playbook](https://github.com/githubixx/ansible-kubernetes-playbooks/tree/v15.0.0_r1.27.5/kubeauthconfig)).
178 | - When downloading the Kubernetes binaries the task checks the SHA512 checksum
179 | - Make `kube-scheduler` and `kube-controller-manager` wait until `kube-apiserver` has started and is listening on a port
180 |
181 | - **OTHER CHANGES**
182 | - Extend `k8s_ctl_certificates` (formerly `k8s_certificates`) list by `cert-k8s-scheduler` and `cert-k8s-controller-manager` files. This was needed as the `kubeconfig` files are now generated on the K8s controller nodes and no longer on the Ansible controller host. Previously it was needed to prepare these files upfront before installing this role. That's no longer needed. Also see **FEATURES** list above.
183 | - Use `kubernetes.core.*` modules instead of `kubectl` binary
184 | - Fix some `ansible-lint` issues
185 |
186 | - **MOLECULE**
187 | - Updated all files to reflect the changes introduces with this version
188 | - Tasks for creating `kubeconfig` for `kube-controller-manager`, `kube-scheduler`, `admin` user and `encryption configuration` are no longer needed as they're now part of `kubernetes_controller` role
189 | - Add `haproxy` to Ubuntu 22 hosts to test new `k8s_ctl_api_endpoint_host` and `k8s_ctl_api_endpoint_port` settings
190 | - Add tasks to install [ansible-role-cni](https://github.com/githubixx/ansible-role-cni) and [ansible-role-runc](https://github.com/githubixx/ansible-role-runc)
191 | - Use `kubernetes.core.k8s_info` module instead of calling `kubectl` binary
192 |
193 | ## 21.1.3+1.27.5
194 |
195 | - rename `githubixx.harden-linux` to `githubixx.harden_linux`
196 |
197 | ## 21.1.2+1.27.5
198 |
199 | - rename `githubixx.kubernetes-ca` to `githubixx.kubernetes_ca`
200 |
201 | ## 21.1.1+1.27.5
202 |
203 | - `molecule/default/molecule.yml`: use Ubuntu 20.04 instead of 22.04 for `test-assets` for now because of certificate problems with Python `urllib` module
204 |
205 | ## 21.1.0+1.27.5
206 |
207 | - add support for Ubuntu 22.04
208 |
209 | ## 21.0.0+1.27.5
210 |
211 | - **BREAKING**: `meta/main.yml`: change role_name from `kubernetes-controller` to `kubernetes_controller`. This is a requirement since quite some time for Ansible Galaxy. But the requirement was introduced after this role already existed for quite some time. So please update the name of the role in your playbook accordingly!
212 | - update `k8s_release` to `1.27.5`
213 | - `meta/main.yml`: remove Ubuntu 18.04 as supported OS (reached EOL)
214 |
215 | ## 20.0.1+1.26.8
216 |
217 | - update `k8s_release` to `1.26.8`
218 | - `kube-apiserver` needs to have network-online.target ready
219 | - `kube-controller-manager` needs to have network-online.target ready
220 | - `kube-scheduler` needs to have network-online.target ready
221 |
222 | ## 20.0.0+1.26.4
223 |
224 | - update `k8s_release` to `1.26.4`
225 | - add Molecule test
226 | - add Github workflow
227 |
228 | ## 19.2.0+1.25.9
229 |
230 | - update `k8s_release` to `1.25.9`
231 | - `kube-apiserver`: remove `--apiserver-count` flag. It has been deprecated and will be removed in a future K8s release.
232 | - `templates/var/lib/kube-scheduler/kube-scheduler.yaml.j2`: `KubeSchedulerConfiguration v1beta2` is deprecated in Kubernetes v1.25, will be removed in v1.26
233 |
234 | ## 19.1.0+1.25.5
235 |
236 | - Introduce `k8s_controller_delegate_to` variable. By default it's set to `127.0.0.1` and reflects the same value as before.
237 |
238 | ## 19.0.0+1.25.5
239 |
240 | - update `k8s_release` to `1.25.5`
241 |
242 | ## 18.0.1+1.24.9
243 |
244 | - update `k8s_release` to `1.24.9`
245 |
246 | ## 18.0.0+1.24.4
247 |
248 | - update `k8s_release` to `1.24.4`
249 |
250 | ## 17.1.0+1.23.10
251 |
252 | - update `k8s_release` to `1.23.10`
253 |
254 | ## 17.0.0+1.23.3
255 |
256 | - update `k8s_release` to `1.23.3`
257 | - add parameter `authentication-kubeconfig`, `authorization-kubeconfig` and `requestheader-client-ca-file` to `k8s_scheduler_settings` (see [K8s Deprecations 1.23](https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.23.md#deprecation))
258 | - remove `healthzBindAddress` and `metricsBindAddress` from `kube-scheduler.yaml.j2` (deprecated)
259 | - this role now requires Ansible >= 2.9
260 |
261 | ## 16.1.0+1.22.6
262 |
263 | - update `k8s_release` to `1.22.6`
264 | - use `kubescheduler.config.k8s.io/v1beta2` in `templates/var/lib/kube-scheduler/kube-scheduler.yaml.j2` (`v1beta1` will be removed in Kubernetes v1.23 - see [Remove scheduler policy config and cc v1beta1](https://github.com/kubernetes/enhancements/issues/2901)
265 |
266 | ## 16.0.0+1.22.5
267 |
268 | - update `k8s_release` to `1.22.5`
269 | - add parameter `authentication-kubeconfig`, `authorization-kubeconfig` and `requestheader-client-ca-file` to `k8s_controller_manager_settings` (see [K8s Deprecations 1.22](https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.22.md#deprecation))
270 | - removed `kubelet-https: "true"` from `k8s_apiserver_settings` as no longer supported by `kube-apiserver` (see: [Mark --kubelet-https deprecated](https://github.com/kubernetes/kubernetes/pull/91630))
271 |
272 | ## 15.0.1+1.21.8
273 |
274 | - update `k8s_release` to `1.21.8`
275 |
276 | ## 15.0.0+1.21.4
277 |
278 | - update `k8s_release` to `1.21.4`
279 | - remove Ubuntu 16.04 support
280 |
281 | ## 14.1.0+1.20.10
282 |
283 | - update `k8s_release` to `1.20.10`
284 |
285 | ## 14.0.0+1.20.8
286 |
287 | - update `k8s_release` to `1.20.8`
288 |
289 | ## 13.1.0+1.19.12
290 |
291 | - update `k8s_release` to `1.19.12`
292 |
293 | ## 13.0.0+1.19.4
294 |
295 | - update 'k8s_release' to `1.19.4`
296 | - `KubeSchedulerConfiguration` graduates to Beta (see [Scheduler Configuration](https://kubernetes.io/docs/reference/scheduling/config)). Upgrade `kubescheduler.config.k8s.io/v1alpha2` to `kubescheduler.config.k8s.io/v1beta1`
297 |
298 | ## 12.2.0+1.18.12
299 |
300 | - update `k8s_release` to `1.18.12`
301 |
302 | ## 12.1.0+1.18.6
303 |
304 | - update `k8s_release` to `1.18.6`
305 | - added `"allocate-node-cidrs": "true"` to`k8s_controller_manager_settings` otherwise `cluster-cidr` setting won't be used by `kube-controller-manager`
306 | - creating ClusterRole's and ClusterRoleBindings is now delegated to `127.0.0.1` (localhost) instead of picking the first Kubernetes controller node for that task
307 |
308 | ## 12.0.1+1.18.5
309 |
310 | - added Ubuntu 20.04 (Focal Fossa) as supported platform
311 |
312 | ## 12.0.0+1.18.5
313 |
314 | - update `k8s_release` to `1.18.5`
315 | - renamed `cert-etcd.pem/cert-etcd-key.pem` to `cert-k8s-apiserver-etcd.pem/cert-k8s-apiserver-etcd-key.pem`. This was also adjusted in `etcd_certificates` list. The changed name makes it more obvious that this is a client certificate for `kube-apiserver` used to connect to a TLS secured `etcd` cluster. In fact `kube-apiserver` is just a client to `etcd` as all clients. In my [ansible-role-kubernetes-ca](https://github.com/githubixx/ansible-role-kubernetes-ca) this was also changed accordingly (see `etcd_additional_clients` list). [ansible-role-kubernetes-ca](https://github.com/githubixx/ansible-role-kubernetes-ca) is now able to generate client certificates for other services like Traefik or Cilium which are often used in a Kubernetes cluster. So the already existing `etcd` cluster for Kubernetes (esp. for `kube-apiserver`) can be reused for other components.
316 | - replaced `cluster-signing-cert-file": "{{k8s_conf_dir}}/ca-k8s-apiserver.pem` with `cluster-signing-cert-file": "{{k8s_conf_dir}}/cert-k8s-apiserver.pem` in `k8s_controller_manager_settings`
317 | - removed deprecated `port` setting in `k8s_controller_manager_settings` which was replaced by `secure-port` setting (default value `10257`)
318 | - removed `k8s_apiserver_secure_port` as it makes no sense. The value `6443` can be set in `k8s_apiserver_settings` (`"secure-port": "6443"`) as it is not used elsewhere
319 | - `kubescheduler.config.k8s.io/v1alpha1` changed to `kubescheduler.config.k8s.io/v1alpha2` in `kube-scheduler.yaml.j2` (see: [CHANGELOG](https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.18.md#kube-scheduler-1))
320 |
321 | ## 11.0.0+1.17.4
322 |
323 | - update `k8s_release` to `1.17.4`
324 | - `rbac.authorization.k8s.io/v1beta1` changed to `rbac.authorization.k8s.io/v1`
325 | - update `runtime-config` (needs boolean expression now)
326 |
327 | ## 10.1.1+1.16.8
328 |
329 | - update `k8s_release` to `1.16.8`
330 |
331 | ## Remove old tags
332 |
333 | - The following tags are removed as they're not compatible with Ansible Galaxy and I guess nobody uses them anymore:
334 |
335 | ```bash
336 | r2.0.0_v1.9.0
337 | r2.0.1_v1.9.0
338 | r2.0.2_v1.9.1
339 | r3.0.0_v1.9.1
340 | r3.0.0_v1.9.3
341 | r3.0.0_v1.9.8
342 | r4.0.1_v1.10.4
343 | r4.0.2_v1.10.4
344 | r4.0.3_v1.10.4
345 | r4.0.4_v1.10.8
346 | r5.0.1_v1.12.3
347 | v1.0.0_r1.5.1
348 | v1.0.0_v1.8.0
349 | v1.0.0_v1.8.2
350 | v1.1.0_v1.8.4
351 | v1.1.1_v1.8.4
352 | v1.1.2_v1.8.4
353 | v1.2.0_v1.8.4
354 | ```
355 |
356 | ## 10.1.0+1.16.3
357 |
358 | - strengthen file permissions for certificate files and other config files
359 |
360 | ## 10.0.0+1.16.3
361 |
362 | - update `k8s_release` to `1.16.3`
363 | - remove deprecated `enable-swagger-ui` option from `kube-apiserver`
364 |
365 | ## 9.0.0+1.15.6
366 |
367 | - update `k8s_release` to `1.15.6`
368 |
369 | ## 9.0.0+1.15.3
370 |
371 | - update `k8s_release` to `1.15.3`
372 |
373 | ## 8.0.1+1.14.6
374 |
375 | - update `k8s_release` to `1.14.6`
376 |
377 | ## 8.0.0+1.14.2
378 |
379 | - update `k8s_release` to `1.14.2`
380 | - add all admissions plugins to `enable-admission-plugins` option that are enabled by default in K8s 1.14
381 | - remove `Initializers` admission plugin (no longer available in 1.14)
382 |
383 | ## 7.0.0+1.13.5
384 |
385 | - update `k8s_release` to `1.13.5`
386 | - introduce `bind-address` flag and bind on VPN IP by default
387 | - introduce `port` flag for kube-controller-manager and set value to 0 to disable unsecure port
388 |
389 | ## 6.0.0+1.13.2
390 |
391 | - update `k8s_release` to `1.13.2`
392 | - kube-apiserver: `--experimental-encryption-provider-config` flag is deprecated and replaced in favor of `--encryption-provider-config`
393 | - kube-apiserver: the configuration file referenced by `--encryption-provider-config` now uses `kind: EncryptionConfiguration` and `apiVersion: apiserver.config.k8s.io/v1`. Support for `kind: EncryptionConfig` and `apiVersion: v1` is deprecated and will be removed in a future release. See [kubeencryptionconfig](https://github.com/githubixx/ansible-kubernetes-playbooks/tree/master/kubeencryptionconfig) and [Kubernetes the not so hard way with Ansible - Certificate authority](https://www.tauceti.blog/post/kubernetes-the-not-so-hard-way-with-ansible-certificate-authority/) (search for `kubeencryptionconfig.yml`). To avoid deprecation warnings it makes sense to create a new `encryption-config.yaml` before running this role to update `kube-apiserver`.
394 | - use correct semantic versioning as described in [semver](https://semver.org). Needed for Ansible Galaxy importer as it now insists on using semantic versioning.
395 | - make Ansible linter happy
396 |
397 | ## r5.0.1_v1.12.3
398 |
399 | - update `k8s_release` to `1.12.3`
400 | - kube-apiserver: added `Priority` admission plugin
401 | - kube-scheduler: deprecated group version changed from `componentconfig/v1alpha1` to `kubescheduler.config.k8s.io/v1alpha1`
402 | - kube-controller-manager: replace deprecated `--address` setting with `--bind-address`
403 |
404 | ## r5.0.0_v1.11.3
405 |
406 | - update `k8s_release` to `1.11.3`
407 |
408 | ## r4.0.4_v1.10.8
409 |
410 | - update `k8s_release` to `1.10.8`
411 |
412 | ## r4.0.3_v1.10.4
413 |
414 | - support Ubuntu 18.04
415 |
416 | ## r4.0.2_v1.10.4
417 |
418 | - wait for kube-apiserver on port 8080 no longer needed (fixes [#11](https://github.com/githubixx/ansible-role-kubernetes-controller/issues/11))
419 |
420 | ## r4.0.0_v1.10.4
421 |
422 | - update `k8s_release` to `1.10.4`
423 | - removed deprecated kube-apiserver parameter `insecure-bind-address` (see: [#59018](https://github.com/kubernetes/kubernetes/pull/59018))
424 | - added variable `k8s_apiserver_secure_port: 6443`
425 | - added parameter `secure-port` to `k8s_apiserver_settings` parameter list
426 | - added `kube-controller-manager-ca` certificate files to `k8s_certificates` list
427 | - added variable `k8s_controller_manager_conf_dir` / added kubeconfig for kube-controller-manager
428 | - added variable `k8s_scheduler_conf_dir` / added kubeconfig for kube-scheduler / settings for kube-scheduler now in `templates/var/lib/kube-scheduler/kube-scheduler.yaml.j2`
429 | - added kubeconfig for `admin` user (located by default in `k8s_conf_dir`). This `admin.kubeconfig` will be needed for `kubectl`
430 | - new `service-account-key-file` value for kube-apiserver
431 | - changes in `k8s_controller_manager_settings`: removed `master` parameter, added `kubeconfig`, new value for `service-account-private-key-file`, new parameter `use-service-account-credentials`
432 |
433 | ## r3.0.0_v1.9.8
434 |
435 | - update `k8s_release` to `1.9.8`
436 |
437 | ## r3.0.0_v1.9.3
438 |
439 | - update `k8s_release` to `1.9.3`
440 |
441 | ## r3.0.0_v1.9.1
442 |
443 | - move advertise-address,bind-address,insecure-bind-address out of kube-apiserver.service.j2 template
444 | - move address,master settings out of kube-controller-manager.service.j2 template / fix variable bug in `k8s_apiserver_settings`
445 | - move address,master settings out of kube-scheduler.service.j2 template
446 | - fix: use `k8s_etcd` hosts group instead of `k8s_controller` group to generate etcd server list
447 | - we need to wait for kube-apiserver port 8080 to become ready before running kubectl tasks
448 |
449 | ## r2.0.2_v1.9.1
450 |
451 | - update to Kubernetes v1.9.1
452 |
453 | ## r2.0.1_v1.9.0
454 |
455 | - removed duplicate key cluster-signing-cert-file from `k8s_controller_manager_settings` dictionary
456 |
457 | ## r2.0.0_v1.9.0
458 |
459 | - introduce flexible parameter settings for API server via `k8s_apiserver_settings/k8s_apiserver_settings_user`
460 | - introduce flexible parameter settings for controller manager via `k8s_controller_manager_settings/k8s_controller_manager_settings_user`
461 | - introduce flexible parameter settings for kube-scheduler via `k8s_scheduler_settings/k8s_scheduler_settings_user`
462 | - change defaults for `k8s_ca_conf_directory` and `k8s_config_directory` variables
463 | - update to Kubernetes v1.9.0
464 |
465 | No changelog for releases < r2.0.0_v1.9.0 (see commit history if needed)
466 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | {project} Copyright (C) {year} {fullname}
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------