This repository has been archived by the owner on May 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
docker-sql-k8s-install.sh
executable file
·64 lines (53 loc) · 5.44 KB
/
docker-sql-k8s-install.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
#! /usr/bin/env bash
set -Eeuxo pipefail
kubectl --namespace kube-system create serviceaccount tiller || true
kubectl create clusterrolebinding tiller \
--clusterrole cluster-admin \
--serviceaccount=kube-system:tiller || true
helm init --upgrade --wait --service-account tiller || true
AIRFLOW_NAMESPACE=default
AIRFLOW_DATABASE_USER=airflow
POSTGRES_ADMIN_PASSWORD=airflow
AIRFLOW_DATABASE_NAME=airflow
POSTGRES_SERVICE=airflow-postgres-postgresql
POSTGRES_PORT=5432
AIRFLOW_DATABASE_USER_PASSWORD=airflow
KUBECONFIG_FILE_OUTPUT=/tmp/kubeconfig
helm upgrade \
--install \
airflow-postgres \
stable/postgresql \
--version 0.15.0 \
--namespace $AIRFLOW_NAMESPACE \
--set postgresPassword=$POSTGRES_ADMIN_PASSWORD \
--set postgresUser=$AIRFLOW_DATABASE_USER \
--set postgresDatabase=$AIRFLOW_DATABASE_USER_PASSWORD
SQL_ALCHEMY_CONN=postgresql+psycopg2://$AIRFLOW_DATABASE_USER:$AIRFLOW_DATABASE_USER_PASSWORD@$POSTGRES_SERVICE:$POSTGRES_PORT/$AIRFLOW_DATABASE_NAME
FERNET_KEY=tpiIe17JmQ8slUcYBlHDLFEkgXkSAkLOP3wAdl+5s+4=
cat <<EOF > /tmp/kubeconfig
apiVersion: v1
clusters:
- cluster:
insecure-skip-tls-verify: true
server: https://localhost:6443
name: docker-for-desktop-cluster
current-context: docker-for-desktop
kind: Config
preferences: {}
users:
- name: docker-for-desktop
user:
client-certificate-data: LS0tLS1CRUdJTiBDRVJ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Fob3RtQXdPR0RLU0VscC9LT3pSM0RrVCs5TUJ0NTd1YlV1ajEKTEp0ZE1zUkswL0Q4UWJaaFBLV3hVaEkyZjN5ZkhUOCtkcmRickhjTlBzRk90MGxuclZSNXVXN3JJNXZYcXIxdwoxVHpjdkFGVStOTDBOZ090elV1Q3ZrZHRkM0ZsOWFub2hRK1YvQlcyNlVQT291NmFvRjZQTHRZRTlFdTVyejRvCkJEWTVBb0dCQU9FRy9CQytDNGQ3NFRsbmphTzVRc0luMWhTUDVOVUE5S2kvMlpDN3U1OFpqUm9uU3BUY3lUcjkKKzVabDNwaTlIT3p4RzQvMUY5b3Nwd1JURGhuV1FVakUvcVJHQkdDVXg4TzBkYWtZQW5XeGhOb0RVTCswNENJNwpnYkN3WmdPNVl4d2djNlRuOVdTT0RDeFJ0am5US2xaNDdsa1RkMXRnLzVHbGp5YWIyTVZ6Ci0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg==
EOF
kubectl create secret generic airflow \
--namespace=$AIRFLOW_NAMESPACE \
--from-literal=fernet-key=$FERNET_KEY \
--from-literal=sql_alchemy_conn=$SQL_ALCHEMY_CONN \
--from-file=kubeconfig=$KUBECONFIG_FILE_OUTPUT || true
# Label the docker node the same as the workers will have in your dags in staging/production
kubectl label node \
docker-for-desktop \
airflow=airflow_workers \
pool=preemptible \
--overwrite