forked from DefrostedTuna/kubernetes-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinit-cluster.sh
executable file
·151 lines (127 loc) · 5.74 KB
/
init-cluster.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/bash
set -e
BASEDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )
source "${BASEDIR}/scripts/functions.sh"
# ------------------------------------------------------------------------------
# Introduction
# ------------------------------------------------------------------------------
echo
echo -e "This script will eases the process of setting up a" \
"Kubernetes cluster, for CI/CD purposes, from scratch on" \
"DigitalOcean. It first checks for any necessary" \
"dependencies and installs them if necessary. After" \
"this you will be guided through each step of the process," \
"being prompted for the necessary information needed for configuration." | fold -s
echo
read -p $'\033[33mPress enter to continue...\033[39m'
echo "Install started $(date)"
echo
# ------------------------------------------------------------------------------
# Check Dependencies: Brew, Kubectl, Helm, Doctl.
# ------------------------------------------------------------------------------
if ask "Locally, you will need some common tools as prerequisites.\nInstall these local CLI tools: Kubectl, Helm, Doctl, and Halyard (hal)?" Y; then
echo
"${BASEDIR}"/scripts/dependency-check.sh
else
echo
fi
echo
# ------------------------------------------------------------------------------
# Create Cluster
# ------------------------------------------------------------------------------
if ask "A Kubernetes cluster on DigitalOcean (DOKS) is needed.\nCreate a new Kubernetes cluster?"; then
echo
"${BASEDIR}"/scripts/create-cluster.sh
else # Copy Config
echo
if ask "Apply the existing Kubernetes config to kubectl context?" Y; then
echo
"${BASEDIR}"/scripts/copy-config.sh
fi
fi
echo
# ------------------------------------------------------------------------------
# Cluster Initializaton (Helm/Tiller)
# ------------------------------------------------------------------------------
if ask "Helm is a package manager for Kubernetes.\nInstall Helm and initialize its Tiller component?" Y; then
echo
"${BASEDIR}"/scripts/install-helm-tiller.sh
fi
echo
# ------------------------------------------------------------------------------
# Dashboard Setup
# ------------------------------------------------------------------------------
if ask "Kubernetes has a generic dashboard for administration.\nInstall the Kubernetes Dashboard?" Y; then
echo
"${BASEDIR}"/scripts/install-dashboard.sh
fi
echo
# ------------------------------------------------------------------------------
# Nginx Ingress Setup
# ------------------------------------------------------------------------------
if ask "Inbound cluster traffic is routed through a Kubernetes Ingress.\nInstall the Nginx Ingress controller?" Y; then
echo
"${BASEDIR}"/scripts/install-nginx-ingress.sh
fi
echo
# ------------------------------------------------------------------------------
# Create DNS A Record for Ingress Setup
# ------------------------------------------------------------------------------
if ask "Traffic routed from a DNS needs to be fed to a load balancer via an A record.\nCreate a DNS A record for the cluster's Ingress?" Y ;then
echo
"${BASEDIR}"/scripts/create-dns.sh
fi
echo
# ------------------------------------------------------------------------------
# Certificate Manager Setup
# ------------------------------------------------------------------------------
if ask "Inbound traffic must be https with TLS certificates.\nInstall a certificate manager (cert-manager)?" Y; then
echo
"${BASEDIR}"/scripts/install-cert-manager.sh
fi
echo
# ------------------------------------------------------------------------------
# Vault Setup
# ------------------------------------------------------------------------------
if ask "Vault: This is under construction and experimental.\nVault secures, stores, and tightly controls access to tokens, passwords, certificates, API keys, and other secrets.\nInstall and configure Vault?" N; then
echo
"${BASEDIR}"/scripts/install-vault.sh
fi
echo
# ------------------------------------------------------------------------------
# Harbor Setup
# ------------------------------------------------------------------------------
if ask "Harbor is a registry tool for holding artifacts such as containers and Helm charts.\nInstall and configure Harbor?" Y; then
echo
"${BASEDIR}"/scripts/install-harbor.sh
fi
echo
echo "Your Kubernetes cluster install and provisioning is complete. $(date)"
# ------------------------------------------------------------------------------
# Jenkins Setup
# ------------------------------------------------------------------------------
if ask "Jenkins is a continuous integration (CI) tool.\nInstall and configure Jenkins?" Y; then
echo
"${BASEDIR}"/scripts/install-jenkins.sh
fi
echo
# ------------------------------------------------------------------------------
# Sonarqube Setup
# ------------------------------------------------------------------------------
if ask "Sonarqube is a tool used to analyze code for smells and other bugs.\nInstall and configure Sonarqube?" Y; then
echo
"${BASEDIR}"/scripts/install-sonarqube.sh
fi
echo
# ------------------------------------------------------------------------------
# Spinnaker Setup
# ------------------------------------------------------------------------------
if ask "Spinnaker is a continuous deliver pipeline tool for distributing your applications to cluster.\nThis is under construction and experimental.\nInstall and configure Spinnaker?" N; then
echo
"${BASEDIR}"/scripts/install-spinnaker.sh
fi
echo
# ------------------------------------------------------------------------------
# La fin
# ------------------------------------------------------------------------------
echo "Your Kubernetes cluster provisioning is complete. $(date)"