From 81b849dd0fe69276453ebb054b34c053d33fd3a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E6=8C=AF=E5=AE=87?= <> Date: Sun, 12 Jan 2025 01:47:07 +0800 Subject: [PATCH] feat(deploy): add deployment script with pre-checks and ansible-playbook execution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙振宇 <> --- cluster/ansible/deploy.sh | 23 +++++++++++++++++++ .../group_vars/k8s_cluster/k8s-cluster.yml | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 cluster/ansible/deploy.sh diff --git a/cluster/ansible/deploy.sh b/cluster/ansible/deploy.sh new file mode 100644 index 00000000..ef75eb19 --- /dev/null +++ b/cluster/ansible/deploy.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -eu -o pipefail + +# Check if `init.sh` has not run +if [ ! -d venv ]; then + echo "Please run init.sh first." + exit 1 +fi + +# Check if kubespray has not been cloned and its empty +if [ ! -d ../../3rd/kubespray ]; then + echo "Please run 'git submoudle --init --recursive' first." + exit 1 +fi + +# Check if `inventory.ini` has not been created +if [ ! -f ../../cluster/ansible/manifests/inventory.ini ]; then + echo "Please create your own inventory.ini first." + exit 1 +fi + +cd ../../3rd/kubespray && ansible-playbook -i ../../cluster/ansible/manifests/inventory.ini ./cluster.yml -kK \ No newline at end of file diff --git a/cluster/ansible/manifests/group_vars/k8s_cluster/k8s-cluster.yml b/cluster/ansible/manifests/group_vars/k8s_cluster/k8s-cluster.yml index 0b3ac911..d55be4d0 100644 --- a/cluster/ansible/manifests/group_vars/k8s_cluster/k8s-cluster.yml +++ b/cluster/ansible/manifests/group_vars/k8s_cluster/k8s-cluster.yml @@ -26,7 +26,7 @@ local_release_dir: "/tmp/releases" retry_stagger: 5 # This is the user that owns tha cluster installation. -kube_owner: kube +kube_owner: root # This is the group that the cert creation scripts chgrp the # cert files to. Not really changeable...