Skip to content

Commit 8fb3ed2

Browse files
Merge pull request #25 from codefresh-io/revert-back-to-dca00c6
Reverting back to dca00c6
2 parents 9ff5ac5 + 31e78f9 commit 8fb3ed2

File tree

3 files changed

+12
-68
lines changed

3 files changed

+12
-68
lines changed

Dockerfile

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,24 @@
1-
FROM alpine:3.9 AS builder
1+
FROM alpine:3.6 AS builder
22

33
RUN apk update && apk add curl
44

5-
RUN curl -o kubectl1.15 -L https://storage.googleapis.com/kubernetes-release/release/v1.15.0/bin/linux/amd64/kubectl
65
RUN curl -o kubectl1.14 -L https://storage.googleapis.com/kubernetes-release/release/v1.14.0/bin/linux/amd64/kubectl
7-
RUN curl -o kubectl1.13 -L https://storage.googleapis.com/kubernetes-release/release/v1.13.0/bin/linux/amd64/kubectl
8-
RUN curl -o kubectl1.12 -L https://storage.googleapis.com/kubernetes-release/release/v1.12.0/bin/linux/amd64/kubectl
9-
RUN curl -o kubectl1.11 -L https://storage.googleapis.com/kubernetes-release/release/v1.11.0/bin/linux/amd64/kubectl
6+
RUN curl -o kubectl1.15 -L https://storage.googleapis.com/kubernetes-release/release/v1.15.0/bin/linux/amd64/kubectl
107
RUN curl -o kubectl1.10 -L https://storage.googleapis.com/kubernetes-release/release/v1.10.0/bin/linux/amd64/kubectl
11-
RUN curl -o kubectl1.9 -L https://storage.googleapis.com/kubernetes-release/release/v1.9.0/bin/linux/amd64/kubectl
128
RUN curl -o kubectl1.6 -L https://storage.googleapis.com/kubernetes-release/release/v1.6.0/bin/linux/amd64/kubectl
139

14-
FROM alpine:3.9
10+
11+
FROM alpine:3.6
1512

1613
RUN apk add --update bash
1714

1815
#copy all versions of kubectl to switch between them later.
1916
COPY --from=builder kubectl1.15 /usr/local/bin/
2017
COPY --from=builder kubectl1.14 /usr/local/bin/
21-
COPY --from=builder kubectl1.13 /usr/local/bin/
22-
COPY --from=builder kubectl1.12 /usr/local/bin/
23-
COPY --from=builder kubectl1.11 /usr/local/bin/
24-
COPY --from=builder kubectl1.10 /usr/local/bin/
25-
COPY --from=builder kubectl1.9 /usr/local/bin/
18+
COPY --from=builder kubectl1.10 /usr/local/bin/kubectl
2619
COPY --from=builder kubectl1.6 /usr/local/bin/
2720

28-
# Set Default
29-
COPY --from=builder kubectl1.6 /usr/local/bin/kubectl
30-
31-
RUN chmod +x /usr/local/bin/kubectl /usr/local/bin/kubectl1.6 /usr/local/bin/kubectl1.9 /usr/local/bin/kubectl1.10 /usr/local/bin/kubectl1.11 /usr/local/bin/kubectl1.12 /usr/local/bin/kubectl1.13 /usr/local/bin/kubectl1.14 /usr/local/bin/kubectl1.15
21+
RUN chmod +x /usr/local/bin/kubectl /usr/local/bin/kubectl1.6 /usr/local/bin/kubectl1.14 /usr/local/bin/kubectl1.15
3222

3323
WORKDIR /
3424

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ The following env variables control the deployment configuration:
2424
3. KUBERNETES_NAMESPACE - The namespace to deploy
2525
4. KUBECTL_ACTION - means an action for `kubectl <action>`. Valid values are apply|create|replace. Default is "apply"
2626

27-
Optional:
28-
`SERVER_VERSION` - Manually set the Minor Kubernetes version. Supports 9-15.
29-
If left blank version 13 and older will use kubectl v1.6.0
30-
3127
# Usage in codefresh.io
3228

3329
### deployment.yml

cf-deploy-kubernetes.sh

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -59,54 +59,12 @@ else
5959
fi
6060
fi
6161

62-
# Add SERVER_VERSION override and testing capabilities
63-
64-
if [[ -n "${SERVER_VERSION}" ]]; then
65-
# Dynamically define SERVER_VERSION using kube context
66-
echo "Statically defined version: ${SERVER_VERSION}"
67-
KUBE_CTL=${SERVER_VERSION}
68-
else
69-
# Dynamically define SERVER_VERSION using kube context
70-
SERVER_VERSION=$(kubectl version --short=true --context "${KUBECONTEXT}" | grep -i server | cut -d ':' -f2 | cut -d '.' -f2 | sed 's/[^0-9]*//g')
71-
echo "Dynamically defined version: ${SERVER_VERSION}"
72-
fi
73-
74-
# Determine appropriate kubectl version if not statically set
75-
if [[ -z "${KUBE_CTL}" ]]; then
76-
if [[ "${SERVER_VERSION}" -eq "15" ]]; then
77-
KUBE_CTL="15"
78-
elif [[ "${SERVER_VERSION}" -eq "14" ]]; then
79-
KUBE_CTL="14"
80-
elif [[ "${SERVER_VERSION}" -le "13" && "${SERVER_VERSION}" -ge "6" ]]; then
81-
KUBE_CTL="6"
82-
else
83-
echo "kubectl version: v1.${SERVER_VERSION}"
84-
fatal "Version Not Supported!!!"
85-
exit 1
86-
fi
87-
fi
88-
89-
# Assign kubectl version
90-
echo "Setting kubectl to version 1.${KUBE_CTL}"
91-
cp -f "/usr/local/bin/kubectl1.${KUBE_CTL}" /usr/local/bin/kubectl
92-
93-
# Simple testing logic for making sure versions are set
94-
if [[ -n "${KUBE_CTL_TEST_VERSION}" ]]; then
95-
KUBE_CTL_VERSION=`kubectl version --client --short`
96-
echo "Testing kubectl version is set..."
97-
if [[ "${KUBE_CTL_VERSION}" == *"${KUBE_CTL_TEST_VERSION}"* ]]; then
98-
echo "Version correctly set"
99-
echo "Kubectl Version: ${KUBE_CTL_VERSION}"
100-
echo "Test Version: ${KUBE_CTL_TEST_VERSION}"
101-
exit 0
102-
else
103-
echo "Kubectl Version: ${KUBE_CTL_VERSION}"
104-
echo "Test Version: ${KUBE_CTL_TEST_VERSION}"
105-
fatal "Version Mismatch!!!"
106-
exit 1
107-
fi
108-
fi
109-
62+
#check the cluster version and decide which version of kubectl to use:
63+
SERVER_VERSION=$(kubectl version --short=true --context "${KUBECONTEXT}" | grep -i server | cut -d ':' -f2 | cut -d '.' -f2 | sed 's/[^0-9]*//g')
64+
echo "Server minor version: $SERVER_VERSION"
65+
if (( "$SERVER_VERSION" <= "6" )); then cp -f /usr/local/bin/kubectl1.6 /usr/local/bin/kubectl; fi 2>/dev/null
66+
if (( "$SERVER_VERSION" == "14" )); then cp -f /usr/local/bin/kubectl1.14 /usr/local/bin/kubectl; fi 2>/dev/null
67+
if (( "$SERVER_VERSION" >= "15" )); then cp -f /usr/local/bin/kubectl1.15 /usr/local/bin/kubectl; fi 2>/dev/null
11068
[ ! -f "${deployment_file}" ] && echo "Couldn't find $deployment_file file at $(pwd)" && exit 1;
11169

11270
DEPLOYMENT_FILE=${deployment_file}-$(date '+%y-%m-%d_%H-%M-%S').yml

0 commit comments

Comments
 (0)