Skip to content

Commit

Permalink
Update init
Browse files Browse the repository at this point in the history
Closes #6
  • Loading branch information
edwardtheharris committed Jul 23, 2024
1 parent b470227 commit 5a6abec
Show file tree
Hide file tree
Showing 9 changed files with 220 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ node_modules
package-lock.json
package.json
roles/reset/files/*.reset.md
roles/join/files/*.join.md
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ molecule = "*"
pytest = "*"
pytest-cov = "*"
version-query = "*"
ansible-lint = "*"

[docs]
myst-parser = {extras = ["linkify"], version = "*"}
Expand Down
170 changes: 164 additions & 6 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions roles/init/files/reset.yaml

This file was deleted.

51 changes: 36 additions & 15 deletions roles/init/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
---
###
# ```{rubric} Prep for Kubeadm
# ```
# ---
# Prepare the first control plane for init.
#
# ```{literalinclude} /roles/init/tasks/main.yml
# :language: yaml
# :start-at: "- name: Create kube group\n"
# :end-at: " mode: ugo+rw\n"
# ```
- name: Create kube group
ansible.builtin.group:
name: kube
Expand All @@ -20,13 +31,9 @@
ansible.builtin.file:
dest: /etc/kubeadm/init.token
state: absent

- name: Reset existing cluster
- name: Generate a boostrap token

Check failure on line 34 in roles/init/tasks/main.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

command-instead-of-shell

Use shell only when shell functionality is required.

Check failure on line 34 in roles/init/tasks/main.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

no-changed-when

Commands should not change things if nothing needs doing.
ansible.builtin.shell:
chdir: /etc/kubeadm
cmd: >-
kubeadm token generate > init.token && cat init.token
creates: /etc/kubeadm/init.token
cmd: kubeadm token generate
register: token_out
- name: Template token init config
ansible.builtin.template:
Expand All @@ -35,12 +42,26 @@
owner: kube
group: kube
mode: ugo+rw
# - name: Init new cluster
# ansible.builtin.command:
# chdir: /etc/kubeadm
# cmd: kubeadm init --config init.yaml
# creates: /etc/kubernetes/admin.conf
# register: init_result
# - name: Debug
# ansible.builtin.debug:
# var: init_result
###
# ```{rubric} Init 1
# ```
# ---
# Run the command to initialize the first control plane.
#
# ```{literalinclude} /roles/init/tasks/main.yml
# :language: yaml
# :start-at: "- name: Init new cluster\n"
# ```
- name: Init new cluster
ansible.builtin.shell:
chdir: /etc/kubeadm
cmd: kubeadm init --config init.yaml --upload-certs &> /root/join.md
creates: /etc/kubernetes/admin.conf
register: init_result
- name: Debug
ansible.builtin.debug:
var: init_result
- name: Pull stored output from hosts
ansible.builtin.fetch:
src: /root/join.md
dest: "roles/join/files/{{ inventory_hostname }}.join.md"
6 changes: 3 additions & 3 deletions roles/init/templates/init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ clusterName: breeze-blocks
controllerManager: {}
controlPlaneEndpoint: {{ kcp_aa }}
dns: {}
etcd:
local:
dataDir: /var/lib/etcd
# etcd:
# local:
# dataDir: /var/lib/etcd
imageRepository: registry.k8s.io
kind: ClusterConfiguration
kubernetesVersion: 1.30.0
Expand Down
Empty file removed roles/init/templates/join.yaml
Empty file.
4 changes: 4 additions & 0 deletions roles/join/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- name: Output nothing

Check failure on line 2 in roles/join/tasks/main.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

fqcn[action-core]

Use FQCN for builtin module actions (debug).
debug:
msg: "nothing here"
11 changes: 11 additions & 0 deletions site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,21 @@
# ```
# ---
# This playbook defines the primary site deployment code for this repository.
#
# ```{literalinclude} /site.yml
# :language: yaml
# ```
- name: Reset Kubernetes Control Planes
hosts: kcp
become: true
roles:
- role: reset
tags:
- reset
- name: Initialize the first control plane
hosts: kcp01
become: true
roles:
- role: init
tags:
- init

0 comments on commit 5a6abec

Please sign in to comment.