Fix kube_apply_* and update deploy scripts

This commit is contained in:
Jonas Juselius
2020-11-06 10:17:11 +01:00
parent 073d447455
commit 88b4b7315e
14 changed files with 60 additions and 96 deletions

View File

@@ -7,6 +7,5 @@ charts=(
)
. ../config.sh
kubectl_apply $namespace "${charts[@]}"
kubectl_apply_files $namespace "${charts[@]}"

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash
version="v1.0.4"
namespace=kube-system
version="v1.0.4"
charts=(
cluster-ca.yaml
@@ -10,9 +10,7 @@ charts=(
)
. ../config.sh
kubectl_apply $namespace "${charts[@]}"
kubectl_apply_files $namespace "${charts[@]}"
kubectl apply \
-n $namespace \
--validate=false \

View File

@@ -1,34 +1,45 @@
#!/usr/bin/env bash
vars=(
initca="@initca@"
apiserver="@apiserver@"
cluster="@cluster@"
ingress_nodes="@ingress_nodes@"
filseserver="@fileserver@"
acme_email="@acme_email@"
grafana_ldap_toml="@grafana_ldap_toml@"
grafana_smtp_user="@grafana_smtp_user@"
grafana_smtp_password="@grafana_smtp_password@"
initca="replace_me"
apiserver="replace_me"
cluster="replace_me"
ingress_nodes="[ replace_me"
ingress_replica_count="replace_me"
filseserver="replace_me"
acme_email="replace_me"
grafana_smtp_user="replace_me"
grafana_smtp_password="replace_me"
)
make_substitutions () {
substitute_all () {
read x
for i in "${vars[@]}"; do
subs=("$@")
for i in "${subs[@]}"; do
k=$(echo "$i" | cut -d= -f1)
v=$(echo "$i" | cut -d= -f2)
echo "$x" | sed "s/@$k@/$v/g"
done
}
substitute_defaults () {
substitute_all "${vars[@]}"
}
kubectl_apply () {
ns=$1; shift
read x
namespace=$1; shift
kubectl get ns $namespace 2>&1 >/dev/null || kubectl create ns $namespace
cat $x | substitute_defaults | kubectl -n $namespace apply -f -
}
kubectl_apply_files () {
namespace=$1; shift
charts=("$@")
for i in "${charts[@]}"; do
k=$(echo "$i" | cut -d= -f1)
v=$(echo "$i" | cut -d= -f2)
sed "s/@$k@/$v/g" $i | kubectl apply -n $ns -f -
cat $i | kubectl_apply $namespace
done
}
# vim:ft=sh

View File

@@ -5,15 +5,11 @@ namespace=kube-system
charts=()
. ../config.sh
kubectl_apply "${charts[@]}"
kubectl_apply_files_files "${charts[@]}"
helm template \
-n $namespace \
-f values.yaml \
ingress \
ingress-nginx/ingress-nginx \
| make_substitutions \
| kubectl apply -n $namespace -f -
| kubectl_apply_files $namespace

View File

@@ -271,7 +271,7 @@ controller:
##
podAnnotations: {}
replicaCount: @ingress_replicas@
replicaCount: @ingress_replica_count@
minAvailable: 3

View File

@@ -8,9 +8,7 @@ charts=(
)
. ../config.sh
kubectl_apply $namespace "${charts[@]}"
kubectl_apply_files $namespace "${charts[@]}"
kubectl delete secret cluster-ca -n $namespace
kubectl create secret tls cluster-ca \
--namespace=$namespace --cert=$initca/ca.pem --key=$initca/ca-key.pem

View File

@@ -8,10 +8,8 @@ charts=(
)
. ../config.sh
kubectl create ns $namespace
kubectl_apply $namespace "${charts[@]}"
kubectl_apply_files $namespace "${charts[@]}"
kubectl apply \
-n $namespace \
-f https://raw.githubusercontent.com/kubernetes/dashboard/$version/aio/deploy/recommended.yaml
-n $namespace \
-f https://raw.githubusercontent.com/kubernetes/dashboard/$version/aio/deploy/recommended.yaml

View File

@@ -5,15 +5,12 @@ namespace=kube-system
charts=()
. ../config.sh
kubectl_apply $namespace "${charts[@]}"
kubectl_apply_files $namespace "${charts[@]}"
helm template \
-n $namespace \
-f values.yaml \
metrics-server \
stable/metrics-server \
| make_substitutions \
| sed 's/8443/6443/g' \
| kubectl apply -f -
| kubectl_apply $namespace

View File

@@ -5,14 +5,10 @@ namespace=minio
charts=()
. ../config.sh
kubectl create ns $namespace
kubectl_apply $namespace "${charts[@]}"
kubectl_apply_files $namespace "${charts[@]}"
helm template \
-n $namespace \
-f values.yaml \
minio minio/minio \
| make_substitutions \
| kubectl apply -n $namespace -f -
| kubectl_apply $namespace

View File

@@ -5,14 +5,12 @@ namespace=kube-system
charts=()
. ../config.sh
kubectl_apply $namespace "${charts[@]}"
kubectl_apply_files $namespace "${charts[@]}"
helm template \
-n $namespace \
-f values.yaml \
nfs-client-provisioner \
stable/nfs-client-provisioner \
| make_substitutions \
| kubectl apply -n $namespace -f -
| kubectl_apply $namespace

View File

@@ -4,20 +4,17 @@ crd_version="v0.42.0"
namespace=prometheus
charts=(
etcd-cert-secret.yaml
app-servicemonitor.yaml
grafana-ldap-toml.yaml
grafana-smtp-secret.yaml
etcd-cert-secret.yaml
prometheus-etcd-cert.yaml
app-servicemonitor.yaml
gitlab-redis-servicemonitor.yaml
gitlab-servicemonitor.yaml
ingress-nginx-servicemonitor.yaml
)
. ../config.sh
install_prometheus_crds () {
crd=(
crds=(
monitoring.coreos.com_alertmanagers.yaml
monitoring.coreos.com_podmonitors.yaml
monitoring.coreos.com_probes.yaml
@@ -26,32 +23,19 @@ install_prometheus_crds () {
monitoring.coreos.com_servicemonitors.yaml
monitoring.coreos.com_thanosrulers.yaml
)
url=https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.42.0/example/prometheus-operator-crd/
for i in ${crd[@]}; do
url=https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/$crd_version/example/prometheus-operator-crd/
for i in ${crds[@]}; do
kubectl apply -f $url/$i
done
}
disable_unset () {
read yaml
# disable ldap for grafana
[ -z "$grafana_ldap_toml" ] && \
echo "$yaml" | sed '/auth\.ldap:/,+1 s/true/false/; /ldap:/,+1 d' | read yaml
# disable storage
[ -z "$fileserver" ] && \
echo "$yaml" | sed '/prometheusSpec:/,+10d' $1 | read yaml
echo $yaml
}
kubectl create ns $namespace
. ../config.sh
install_prometheus_crds
kubectl_apply $namespace "${charts[@]}"
kubectl_apply_files $namespace "${charts[@]}"
helm template \
-n $namespace \
-f values.yaml \
prometheus \
prometheus-community/kube-prometheus-stack \
| make_substitutions \
| kubectl -n $namespace -f -
-n $namespace \
-f values.yaml \
prometheus \
prometheus-community/kube-prometheus-stack \
| kubectl_apply $namespace

View File

@@ -5,14 +5,10 @@ namespace=sentry
charts=()
. ../config.sh
kubectl create ns $namespace
kubectl_apply $namespace "${charts[@]}"
kubectl_apply_files $namespace "${charts[@]}"
helm template \
-n $namespace \
-f values.yaml \
sentry stable/sentry \
| make_substitutions \
| kubectl apply -n $namespace -f -
| kubectl_apply $namespace

View File

@@ -5,14 +5,10 @@ namespace=seq
charts=()
. ../config.sh
kubectl create ns $namespace
kubectl_apply $namespace "${charts[@]}"
kubectl_apply_files $namespace "${charts[@]}"
helm template \
-n $namespace \
-f values.yaml \
seq stable/seq \
| make_substitutions \
| kubectl apply -n $namespace -f -
| kubectl_apply $namespace

View File

@@ -5,13 +5,10 @@ namespace=vault
charts=()
. ../config.sh
kubectl create ns $namespace
kubectl_apply $namespace "${charts[@]}"
kubectl_apply_files $namespace "${charts[@]}"
helm template \
-n $namespace \
-f vault-values.yaml \
vault hashicorp/vault \
| make_substitutions \
| kubectl apply -n $namespace -f -
| kubectl_apply $namespace