-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·68 lines (58 loc) · 2.43 KB
/
Copy pathentrypoint.sh
File metadata and controls
executable file
·68 lines (58 loc) · 2.43 KB
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/sh
set -e
# Set default TARGETARCH if not provided
if [ -z "$TARGETARCH" ]; then
export TARGETARCH=amd64
fi
# Check if KUBE_CONFIG_DATA environment variable is set
if [ -z "$KUBE_CONFIG_DATA" ]; then
echo "Error: KUBE_CONFIG_DATA environment variable is not set"
exit 1
fi
# Extract the base64 encoded config data and write this to the KUBECONFIG
echo "$KUBE_CONFIG_DATA" | base64 -d > /tmp/config
export KUBECONFIG=/tmp/config
# Check if config was successfully decoded
if [ ! -s /tmp/config ]; then
echo "Error: Failed to decode KUBE_CONFIG_DATA"
exit 1
fi
# Handle kubectl version if specified
if [ ! -z "${KUBECTL_VERSION}" ]; then
if [ ! -e /usr/bin/kubectl-${KUBECTL_VERSION} ]; then
echo "Pulling kubectl for version $KUBECTL_VERSION"
curl -sL -o /usr/bin/kubectl-${KUBECTL_VERSION} https://storage.googleapis.com/kubernetes-release/release/"$KUBECTL_VERSION"/bin/linux/$TARGETARCH/kubectl && \
chmod +x /usr/bin/kubectl-${KUBECTL_VERSION} && \
ln -f -s /usr/bin/kubectl-${KUBECTL_VERSION} /usr/bin/kubectl
else
ln -f -s /usr/bin/kubectl-${KUBECTL_VERSION} /usr/bin/kubectl
fi
fi
echo "Using kubectl version: $(kubectl version --client 2>&1)"
# Handle aws-iam-authenticator version if specified
if [ ! -z "${IAM_VERSION}" ]; then
if [ ! -e /usr/bin/aws-iam-authenticator-${IAM_VERSION} ]; then
echo "Pulling aws-iam-authenticator for version $IAM_VERSION"
curl -sL -o /usr/bin/aws-iam-authenticator-${IAM_VERSION} https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v"$IAM_VERSION"/aws-iam-authenticator_"$IAM_VERSION"_linux_$TARGETARCH && \
chmod +x /usr/bin/aws-iam-authenticator-${IAM_VERSION} && \
ln -f -s /usr/bin/aws-iam-authenticator-${IAM_VERSION} /usr/bin/aws-iam-authenticator
else
ln -f -s /usr/bin/aws-iam-authenticator-${IAM_VERSION} /usr/bin/aws-iam-authenticator
fi
fi
echo "Using aws-iam-authenticator version: $(aws-iam-authenticator version 2>&1)"
# Check if tools were successfully installed
if ! command -v kubectl >/dev/null 2>&1; then
echo "Error: kubectl is not installed or not executable"
exit 1
fi
if ! command -v aws-iam-authenticator >/dev/null 2>&1; then
echo "Error: aws-iam-authenticator is not installed or not executable"
exit 1
fi
# Execute the command
if [ -z "$RUN_COMMAND" ] ; then
sh -c "kubectl $*"
else
sh -c "kubectl $RUN_COMMAND"
fi