-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathdeploy.sh
executable file
·68 lines (58 loc) · 1.47 KB
/
deploy.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
#!/bin/bash
set -e
#
# Create Secret, ConfigMap, and DaemonSet for fluentd-cloudwatch
#
: ${LOGGING_AWS_ACCESS_KEY_ID?"Must define LOGGING_AWS_ACCESS_KEY_ID"}
: ${LOGGING_AWS_SECRET_ACCESS_KEY?"Must define LOGGING_AWS_SECRET_ACCESS_KEY"}
: ${LOGGING_AWS_REGION?"Must define LOGGING_AWS_REGION"}
: ${APP_NAME:=fluentd-cloudwatch}
: ${SECRET_NAME:=$APP_NAME}
: ${CONFIG_NAME:=$APP_NAME}
: ${ENV_NAME:=system}
: ${NAMESPACE:=kube-system}
: ${IMAGE_NAME:=callstats/fluentd-kubernetes-cloudwatch:v1.1.2}
: ${CW_LOG_GROUP:=kubernetes-cluster}
#
# Secret
#
if [[ "$(kubectl get secret $SECRET_NAME --namespace=$NAMESPACE --output name 2> /dev/null || true)" = "secret/${SECRET_NAME}" ]]; then
ACTION=replace
else
ACTION=create
fi
kubectl $ACTION -f - <<END
apiVersion: v1
kind: Secret
type: kubernetes.io/opaque
metadata:
name: $SECRET_NAME
namespace: $NAMESPACE
labels:
app: $APP_NAME
env: $ENV_NAME
data:
AWS_ACCESS_KEY_ID: $(echo -n "${LOGGING_AWS_ACCESS_KEY_ID}" | base64 -w 0)
AWS_SECRET_ACCESS_KEY: $(echo -n "${LOGGING_AWS_SECRET_ACCESS_KEY}" | base64 -w 0)
END
#
# ConfigMap
#
kubectl apply -f - <<END
apiVersion: v1
kind: ConfigMap
metadata:
name: $CONFIG_NAME
namespace: $NAMESPACE
labels:
app: $APP_NAME
env: $ENV_NAME
data:
AWS_REGION: $LOGGING_AWS_REGION
CW_LOG_GROUP: $CW_LOG_GROUP
END
#
# DaemonSet
#
export APP_NAME ENV_NAME CONFIG_NAME SECRET_NAME NAMESPACE IMAGE_NAME
envsubst < fluentd-cloudwatch-daemonset-template.yaml | kubectl apply -f -