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 . ../config.sh
kubectl_apply_files $namespace "${charts[@]}"
kubectl_apply $namespace "${charts[@]}"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -4,20 +4,17 @@ crd_version="v0.42.0"
namespace=prometheus namespace=prometheus
charts=( charts=(
etcd-cert-secret.yaml
app-servicemonitor.yaml
grafana-ldap-toml.yaml
grafana-smtp-secret.yaml grafana-smtp-secret.yaml
etcd-cert-secret.yaml
prometheus-etcd-cert.yaml prometheus-etcd-cert.yaml
app-servicemonitor.yaml
gitlab-redis-servicemonitor.yaml gitlab-redis-servicemonitor.yaml
gitlab-servicemonitor.yaml gitlab-servicemonitor.yaml
ingress-nginx-servicemonitor.yaml ingress-nginx-servicemonitor.yaml
) )
. ../config.sh
install_prometheus_crds () { install_prometheus_crds () {
crd=( crds=(
monitoring.coreos.com_alertmanagers.yaml monitoring.coreos.com_alertmanagers.yaml
monitoring.coreos.com_podmonitors.yaml monitoring.coreos.com_podmonitors.yaml
monitoring.coreos.com_probes.yaml monitoring.coreos.com_probes.yaml
@@ -26,32 +23,19 @@ install_prometheus_crds () {
monitoring.coreos.com_servicemonitors.yaml monitoring.coreos.com_servicemonitors.yaml
monitoring.coreos.com_thanosrulers.yaml monitoring.coreos.com_thanosrulers.yaml
) )
url=https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.42.0/example/prometheus-operator-crd/ url=https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/$crd_version/example/prometheus-operator-crd/
for i in ${crd[@]}; do for i in ${crds[@]}; do
kubectl apply -f $url/$i kubectl apply -f $url/$i
done done
} }
disable_unset () { . ../config.sh
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
install_prometheus_crds install_prometheus_crds
kubectl_apply $namespace "${charts[@]}" kubectl_apply_files $namespace "${charts[@]}"
helm template \ helm template \
-n $namespace \ -n $namespace \
-f values.yaml \ -f values.yaml \
prometheus \ prometheus \
prometheus-community/kube-prometheus-stack \ prometheus-community/kube-prometheus-stack \
| make_substitutions \ | kubectl_apply $namespace
| kubectl -n $namespace -f -

View File

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

View File

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

View File

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