-
Notifications
You must be signed in to change notification settings - Fork 2
/
entrypoint.sh
executable file
·107 lines (91 loc) · 2.2 KB
/
entrypoint.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
#!/bin/bash
prop () {
grep "${1}" /conf/cluster.conf|cut -d'=' -f2-
}
source ~/.profile
if [ -z $1 ]
then
echo "Please specify command to run. e.g. init, aws, kubectl, helm, linkerd\n"
echo "To install:"
echo " docker run --rm diginex/ca install | sudo sh\n"
echo "To init, please run: "
echo " ca init\n"
echo "Usage:"
echo " ca kubectl get pods"
exit 0
fi
if [ $1 = 'install' ]
then
cat /install.sh
exit 0
fi
if [ $1 = 'getScript' ]
then
cat /ca.sh
exit 0
fi
if [ $1 = 'init' ]
then
cat /init.sh
exit 0
fi
if [ $1 = 'deploy' ]
then
cat /deploy.sh
exit 0
fi
if [ $1 = 'deploychart' ]
then
cat /deploychart.sh
exit 0
fi
if [ $1 = 'builddeploydocker' ]
then
cat /builddeploydocker.sh
exit 0
fi
# TODO
#if [ $1 = 'createdeveloperns' ]
#then
# /createdeveloperns.sh $2 $3
#
# exit 0
#fi
export PATH=$PATH:$HOME/.linkerd2/bin
file="/conf/cluster.conf"
if [ -f "$file" ]
then
export AWS_ACCESS_KEY_ID=$(prop 'aws_access_key_id')
export AWS_SECRET_ACCESS_KEY=$(prop 'aws_secret_access_key')
export AWS_DEFAULT_REGION=$(prop 'aws_default_region')
export KUBE_CLUSTER_NAME=$(prop 'kube_cluster_name')
export KOPS_CLUSTER_NAME=$(prop 'kops_cluster_name')
export KOPS_STATE_STORE=$(prop 'kops_state_store')
export KOPS_CA_DATA=$(prop 'kops_ca_data')
export KOPS_OPERATION_ROLE=$(prop 'kops_operation_role')
fi
if [ ! -z $KUBE_CLUSTER_NAME ]
then
aws eks update-kubeconfig --name $KUBE_CLUSTER_NAME > /dev/null
exec "$@"
exit 0
fi
if [ ! -z $KOPS_CLUSTER_NAME ]
then
if [ ! -z $KOPS_CA_DATA ]
then
ACCOUNT_ID=$(aws sts get-caller-identity --output text --query 'Account')
sed -e "s;%%%KOPS_CA_DATA%%%;$KOPS_CA_DATA;g" -e "s;%%%KOPS_CLUSTER_NAME%%%;$KOPS_CLUSTER_NAME;g" -e "s;%%%ACCOUNT_ID%%%;$ACCOUNT_ID;g" -e "s;%%%KOPS_OPERATION_ROLE%%%;$KOPS_OPERATION_ROLE;g" /kubeconfig.template.yaml | install -D /dev/stdin ~/.kube/config
exec "$@"
exit 0
fi
if [ -z $SUPPRESS_INFO ]
then
kops export kubecfg --name ${KOPS_CLUSTER_NAME}
else
kops export kubecfg --name ${KOPS_CLUSTER_NAME} > /dev/null
fi
exec "$@"
exit 0
fi
exec "$@"