From 5a6abec9b48551ecdaffd62b2e78ff41022ddf00 Mon Sep 17 00:00:00 2001 From: Xander Harris Date: Tue, 23 Jul 2024 13:41:31 -0700 Subject: [PATCH] Update init Closes #6 --- .gitignore | 1 + Pipfile | 1 + Pipfile.lock | 170 +++++++++++++++++++++++++++++++-- roles/init/files/reset.yaml | 12 --- roles/init/tasks/main.yml | 51 +++++++--- roles/init/templates/init.yaml | 6 +- roles/init/templates/join.yaml | 0 roles/join/tasks/main.yml | 4 + site.yml | 11 +++ 9 files changed, 220 insertions(+), 36 deletions(-) delete mode 100644 roles/init/files/reset.yaml delete mode 100644 roles/init/templates/join.yaml create mode 100644 roles/join/tasks/main.yml diff --git a/.gitignore b/.gitignore index 649e792..514c567 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ node_modules package-lock.json package.json roles/reset/files/*.reset.md +roles/join/files/*.join.md diff --git a/Pipfile b/Pipfile index 490aa60..0edd3dc 100644 --- a/Pipfile +++ b/Pipfile @@ -18,6 +18,7 @@ molecule = "*" pytest = "*" pytest-cov = "*" version-query = "*" +ansible-lint = "*" [docs] myst-parser = {extras = ["linkify"], version = "*"} diff --git a/Pipfile.lock b/Pipfile.lock index c6c3725..8847f80 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "dcc5828c7f0ace2107e89c3165308a987191ac98e3125f2169bb0443b0e176b3" + "sha256": "fea64252ca3d6fb524ad711bd245364845fb766f2a1ee1a923b4dfa6a471b691" }, "pipfile-spec": 6, "requires": {}, @@ -790,7 +790,7 @@ "sha256:032d42ee9fb536e33087fb66cac5f840eb9391ed05637b3f2a76a7c8fb477936", "sha256:33874fdc59b3188304b2e7c80d9029097ea31627180896fb549c578ceb8a0855" ], - "markers": "python_version >= '3.8'", + "markers": "python_version >= '3.11'", "version": "==71.1.0" }, "smmap": { @@ -867,6 +867,15 @@ "markers": "python_version >= '3.10'", "version": "==2.17.2" }, + "ansible-lint": { + "hashes": [ + "sha256:a2305f1d69a25be27810c64a32711d1d0463d2fda5b9308166362347aeda36e0", + "sha256:ca2edc7e4e80cf19df4b28cbf4c118f761ce6cdd6a5ef9c8561e454ed7af5a24" + ], + "index": "pypi", + "markers": "python_version >= '3.10'", + "version": "==24.7.0" + }, "argcomplete": { "hashes": [ "sha256:69a79e083a716173e5532e0fa3bef45f793f4e61096cf52b5a42c0211c8b8aa5", @@ -882,6 +891,34 @@ "markers": "python_version >= '3.7'", "version": "==23.2.0" }, + "black": { + "hashes": [ + "sha256:257d724c2c9b1660f353b36c802ccece186a30accc7742c176d29c146df6e474", + "sha256:37aae07b029fa0174d39daf02748b379399b909652a806e5708199bd93899da1", + "sha256:415e686e87dbbe6f4cd5ef0fbf764af7b89f9057b97c908742b6008cc554b9c0", + "sha256:48a85f2cb5e6799a9ef05347b476cce6c182d6c71ee36925a6c194d074336ef8", + "sha256:7768a0dbf16a39aa5e9a3ded568bb545c8c2727396d063bbaf847df05b08cd96", + "sha256:7e122b1c4fb252fd85df3ca93578732b4749d9be076593076ef4d07a0233c3e1", + "sha256:88c57dc656038f1ab9f92b3eb5335ee9b021412feaa46330d5eba4e51fe49b04", + "sha256:8e537d281831ad0e71007dcdcbe50a71470b978c453fa41ce77186bbe0ed6021", + "sha256:98e123f1d5cfd42f886624d84464f7756f60ff6eab89ae845210631714f6db94", + "sha256:accf49e151c8ed2c0cdc528691838afd217c50412534e876a19270fea1e28e2d", + "sha256:b1530ae42e9d6d5b670a34db49a94115a64596bc77710b1d05e9801e62ca0a7c", + "sha256:b9176b9832e84308818a99a561e90aa479e73c523b3f77afd07913380ae2eab7", + "sha256:bdde6f877a18f24844e381d45e9947a49e97933573ac9d4345399be37621e26c", + "sha256:be8bef99eb46d5021bf053114442914baeb3649a89dc5f3a555c88737e5e98fc", + "sha256:bf10f7310db693bb62692609b397e8d67257c55f949abde4c67f9cc574492cc7", + "sha256:c872b53057f000085da66a19c55d68f6f8ddcac2642392ad3a355878406fbd4d", + "sha256:d36ed1124bb81b32f8614555b34cc4259c3fbc7eec17870e8ff8ded335b58d8c", + "sha256:da33a1a5e49c4122ccdfd56cd021ff1ebc4a1ec4e2d01594fef9b6f267a9e741", + "sha256:dd1b5a14e417189db4c7b64a6540f31730713d173f0b63e55fabd52d61d8fdce", + "sha256:e151054aa00bad1f4e1f04919542885f89f5f7d086b8a59e5000e6c616896ffb", + "sha256:eaea3008c281f1038edb473c1aa8ed8143a5535ff18f978a318f10302b254063", + "sha256:ef703f83fc32e131e9bcc0a5094cfe85599e7109f896fe8bc96cc402f3eb4b6e" + ], + "markers": "python_version >= '3.8'", + "version": "==24.4.2" + }, "boilerplates": { "extras": [ "cli", @@ -1084,6 +1121,14 @@ "markers": "python_version >= '3.6'", "version": "==1.2.7" }, + "filelock": { + "hashes": [ + "sha256:2207938cbc1844345cb01a5a95524dae30f0ce089eba5b00378295a17e3e90cb", + "sha256:6ca1fffae96225dab4c6eaf1c4f4f28cd2568d3ec2a44e15a08520504de468e7" + ], + "markers": "python_version >= '3.8'", + "version": "==3.15.4" + }, "gitdb": { "hashes": [ "sha256:81a3407ddd2ee8df444cbacea00e2d038e40150acfa3001696fe0dcf1d3adfa4", @@ -1101,6 +1146,14 @@ "markers": "python_version >= '3.7'", "version": "==3.1.43" }, + "importlib-metadata": { + "hashes": [ + "sha256:3cd29f739ed65973840b068e3132135ce954c254d48b5b640484467ef7ab3c8c", + "sha256:fcdcb1d5ead7bdf3dd32657bb94ebe9d2aabfe89a19782ddc32da5041d6ebfb4" + ], + "markers": "python_version >= '3.8'", + "version": "==8.1.0" + }, "iniconfig": { "hashes": [ "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3", @@ -1224,6 +1277,14 @@ "markers": "python_version >= '3.10'", "version": "==24.7.0" }, + "mypy-extensions": { + "hashes": [ + "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d", + "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782" + ], + "markers": "python_version >= '3.5'", + "version": "==1.0.0" + }, "packaging": { "hashes": [ "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002", @@ -1232,6 +1293,22 @@ "markers": "python_version >= '3.8'", "version": "==24.1" }, + "pathspec": { + "hashes": [ + "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08", + "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712" + ], + "markers": "python_version >= '3.8'", + "version": "==0.12.1" + }, + "platformdirs": { + "hashes": [ + "sha256:2d7a1657e36a80ea911db832a8a6ece5ee53d8de21edd5cc5879af6530b1bfee", + "sha256:38b7b51f512eed9e84a22788b4bce1de17c0adb134d6becb09836e37d8654cd3" + ], + "markers": "python_version >= '3.8'", + "version": "==4.2.2" + }, "pluggy": { "hashes": [ "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1", @@ -1459,6 +1536,70 @@ "markers": "python_version >= '3.8'", "version": "==0.19.0" }, + "ruamel.yaml": { + "hashes": [ + "sha256:57b53ba33def16c4f3d807c0ccbc00f8a6081827e81ba2491691b76882d0c636", + "sha256:8b27e6a217e786c6fbe5634d8f3f11bc63e0f80f6a5890f28863d9c45aac311b" + ], + "markers": "python_version >= '3.7'", + "version": "==0.18.6" + }, + "ruamel.yaml.clib": { + "hashes": [ + "sha256:024cfe1fc7c7f4e1aff4a81e718109e13409767e4f871443cbff3dba3578203d", + "sha256:03d1162b6d1df1caa3a4bd27aa51ce17c9afc2046c31b0ad60a0a96ec22f8001", + "sha256:07238db9cbdf8fc1e9de2489a4f68474e70dffcb32232db7c08fa61ca0c7c462", + "sha256:09b055c05697b38ecacb7ac50bdab2240bfca1a0c4872b0fd309bb07dc9aa3a9", + "sha256:1707814f0d9791df063f8c19bb51b0d1278b8e9a2353abbb676c2f685dee6afe", + "sha256:1758ce7d8e1a29d23de54a16ae867abd370f01b5a69e1a3ba75223eaa3ca1a1b", + "sha256:184565012b60405d93838167f425713180b949e9d8dd0bbc7b49f074407c5a8b", + "sha256:1b617618914cb00bf5c34d4357c37aa15183fa229b24767259657746c9077615", + "sha256:1dc67314e7e1086c9fdf2680b7b6c2be1c0d8e3a8279f2e993ca2a7545fecf62", + "sha256:25ac8c08322002b06fa1d49d1646181f0b2c72f5cbc15a85e80b4c30a544bb15", + "sha256:25c515e350e5b739842fc3228d662413ef28f295791af5e5110b543cf0b57d9b", + "sha256:305889baa4043a09e5b76f8e2a51d4ffba44259f6b4c72dec8ca56207d9c6fe1", + "sha256:3213ece08ea033eb159ac52ae052a4899b56ecc124bb80020d9bbceeb50258e9", + "sha256:3f215c5daf6a9d7bbed4a0a4f760f3113b10e82ff4c5c44bec20a68c8014f675", + "sha256:46d378daaac94f454b3a0e3d8d78cafd78a026b1d71443f4966c696b48a6d899", + "sha256:4ecbf9c3e19f9562c7fdd462e8d18dd902a47ca046a2e64dba80699f0b6c09b7", + "sha256:53a300ed9cea38cf5a2a9b069058137c2ca1ce658a874b79baceb8f892f915a7", + "sha256:56f4252222c067b4ce51ae12cbac231bce32aee1d33fbfc9d17e5b8d6966c312", + "sha256:5c365d91c88390c8d0a8545df0b5857172824b1c604e867161e6b3d59a827eaa", + "sha256:700e4ebb569e59e16a976857c8798aee258dceac7c7d6b50cab63e080058df91", + "sha256:75e1ed13e1f9de23c5607fe6bd1aeaae21e523b32d83bb33918245361e9cc51b", + "sha256:77159f5d5b5c14f7c34073862a6b7d34944075d9f93e681638f6d753606c6ce6", + "sha256:7f67a1ee819dc4562d444bbafb135832b0b909f81cc90f7aa00260968c9ca1b3", + "sha256:840f0c7f194986a63d2c2465ca63af8ccbbc90ab1c6001b1978f05119b5e7334", + "sha256:84b554931e932c46f94ab306913ad7e11bba988104c5cff26d90d03f68258cd5", + "sha256:87ea5ff66d8064301a154b3933ae406b0863402a799b16e4a1d24d9fbbcbe0d3", + "sha256:955eae71ac26c1ab35924203fda6220f84dce57d6d7884f189743e2abe3a9fbe", + "sha256:a1a45e0bb052edf6a1d3a93baef85319733a888363938e1fc9924cb00c8df24c", + "sha256:a5aa27bad2bb83670b71683aae140a1f52b0857a2deff56ad3f6c13a017a26ed", + "sha256:a6a9ffd280b71ad062eae53ac1659ad86a17f59a0fdc7699fd9be40525153337", + "sha256:a75879bacf2c987c003368cf14bed0ffe99e8e85acfa6c0bfffc21a090f16880", + "sha256:aa2267c6a303eb483de8d02db2871afb5c5fc15618d894300b88958f729ad74f", + "sha256:aab7fd643f71d7946f2ee58cc88c9b7bfc97debd71dcc93e03e2d174628e7e2d", + "sha256:b16420e621d26fdfa949a8b4b47ade8810c56002f5389970db4ddda51dbff248", + "sha256:b42169467c42b692c19cf539c38d4602069d8c1505e97b86387fcf7afb766e1d", + "sha256:bba64af9fa9cebe325a62fa398760f5c7206b215201b0ec825005f1b18b9bccf", + "sha256:beb2e0404003de9a4cab9753a8805a8fe9320ee6673136ed7f04255fe60bb512", + "sha256:bef08cd86169d9eafb3ccb0a39edb11d8e25f3dae2b28f5c52fd997521133069", + "sha256:c2a72e9109ea74e511e29032f3b670835f8a59bbdc9ce692c5b4ed91ccf1eedb", + "sha256:c58ecd827313af6864893e7af0a3bb85fd529f862b6adbefe14643947cfe2942", + "sha256:c69212f63169ec1cfc9bb44723bf2917cbbd8f6191a00ef3410f5a7fe300722d", + "sha256:cabddb8d8ead485e255fe80429f833172b4cadf99274db39abc080e068cbcc31", + "sha256:d176b57452ab5b7028ac47e7b3cf644bcfdc8cacfecf7e71759f7f51a59e5c92", + "sha256:da09ad1c359a728e112d60116f626cc9f29730ff3e0e7db72b9a2dbc2e4beed5", + "sha256:e2b4c44b60eadec492926a7270abb100ef9f72798e18743939bdbf037aab8c28", + "sha256:e79e5db08739731b0ce4850bed599235d601701d5694c36570a99a0c5ca41a9d", + "sha256:ebc06178e8821efc9692ea7544aa5644217358490145629914d8020042c24aa1", + "sha256:edaef1c1200c4b4cb914583150dcaa3bc30e592e907c01117c08b13a07255ec2", + "sha256:f481f16baec5290e45aebdc2a5168ebc6d35189ae6fea7a58787613a25f6e875", + "sha256:fff3573c2db359f091e1589c3d7c5fc2f86f5bdb6f24252c2d8e539d4e45f412" + ], + "markers": "python_version < '3.13' and platform_python_implementation == 'CPython'", + "version": "==0.2.8" + }, "semver": { "hashes": [ "sha256:6253adb39c70f6e51afed2fa7152bcd414c411286088fb4b9effb133885ab4cc", @@ -1499,6 +1640,22 @@ ], "markers": "python_version >= '3.12'", "version": "==8.5.2" + }, + "yamllint": { + "hashes": [ + "sha256:2e16e504bb129ff515b37823b472750b36b6de07963bd74b307341ef5ad8bdc3", + "sha256:7a003809f88324fd2c877734f2d575ee7881dd9043360657cc8049c809eba6cd" + ], + "markers": "python_version >= '3.8'", + "version": "==1.35.1" + }, + "zipp": { + "hashes": [ + "sha256:bf1dcf6450f873a13e952a29504887c89e6de7506209e5b1bcc3460135d4de19", + "sha256:f091755f667055f2d02b32c53771a7a6c8b47e1fdbc4b72a8b9072b3eef8015c" + ], + "markers": "python_version >= '3.8'", + "version": "==3.19.2" } }, "docs": { @@ -1929,7 +2086,7 @@ "sha256:032d42ee9fb536e33087fb66cac5f840eb9391ed05637b3f2a76a7c8fb477936", "sha256:33874fdc59b3188304b2e7c80d9029097ea31627180896fb549c578ceb8a0855" ], - "markers": "python_version >= '3.8'", + "markers": "python_version >= '3.11'", "version": "==71.1.0" }, "six": { @@ -1977,6 +2134,7 @@ "sha256:242f92a7ea7e6c5b406fdc2615413890ba9f699114a9c09192d7dfead2ee9cfe", "sha256:c2419e2135d11f1951cd994d6eb18a1835bd8fdd8429f9ca375dc1f3281bd239" ], + "index": "pypi", "markers": "python_version >= '3.9'", "version": "==7.4.7" }, @@ -2086,12 +2244,12 @@ }, "sphinxcontrib-autoyaml": { "hashes": [ - "sha256:13956ba807b31189a4d0a459d762245c2e08d1d5e070a960082e9d3ce216ee54", - "sha256:d4cd04a248742d760d44371419fa3375eff041007fcfdce5907a831ba509110b" + "sha256:117de410bbbae0fd85d28b25c92880e1a18a84afe76c9766c92432253095ba39", + "sha256:dc87ade28d7c5a6e34ccff0d76e99a07c675679b5f2895a68d0dbd0d68e607c9" ], "index": "pypi", "markers": "python_version >= '3.6' and python_version < '4.0'", - "version": "==0.5.0" + "version": "==1.1.1" }, "sphinxcontrib-devhelp": { "hashes": [ diff --git a/roles/init/files/reset.yaml b/roles/init/files/reset.yaml deleted file mode 100644 index 8e4cbbd..0000000 --- a/roles/init/files/reset.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kubeadm.k8s.io/v1beta4 -certificatesDir: /etc/kubernetes/pki -criSocket: unix:///var/run/containerd/containerd.sock -kind: ResetConfiguration -timeouts: - controlPlaneComponentHealthCheck: 4m0s - discovery: 5m0s - etcdAPICall: 2m0s - kubeletHealthCheck: 4m0s - kubernetesAPICall: 1m0s - tlsBootstrap: 5m0s - upgradeManifests: 5m0s diff --git a/roles/init/tasks/main.yml b/roles/init/tasks/main.yml index 5d647ca..0f89b2d 100644 --- a/roles/init/tasks/main.yml +++ b/roles/init/tasks/main.yml @@ -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 @@ -20,13 +31,9 @@ ansible.builtin.file: dest: /etc/kubeadm/init.token state: absent - -- name: Reset existing cluster +- name: Generate a boostrap token 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: @@ -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" diff --git a/roles/init/templates/init.yaml b/roles/init/templates/init.yaml index 0f65a30..e585866 100644 --- a/roles/init/templates/init.yaml +++ b/roles/init/templates/init.yaml @@ -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 diff --git a/roles/init/templates/join.yaml b/roles/init/templates/join.yaml deleted file mode 100644 index e69de29..0000000 diff --git a/roles/join/tasks/main.yml b/roles/join/tasks/main.yml new file mode 100644 index 0000000..d5a9ea4 --- /dev/null +++ b/roles/join/tasks/main.yml @@ -0,0 +1,4 @@ +--- +- name: Output nothing + debug: + msg: "nothing here" diff --git a/site.yml b/site.yml index 29ea544..c549ec9 100644 --- a/site.yml +++ b/site.yml @@ -4,6 +4,10 @@ # ``` # --- # 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 @@ -11,3 +15,10 @@ - role: reset tags: - reset +- name: Initialize the first control plane + hosts: kcp01 + become: true + roles: + - role: init + tags: + - init