Skip to content
This repository was archived by the owner on Jul 28, 2023. It is now read-only.

Commit 898e07c

Browse files
author
Constantine Karnaukhov
committed
feat(Dockerfile): install kubectl and istioctl
1 parent c42fd8e commit 898e07c

File tree

4 files changed

+143
-60
lines changed

4 files changed

+143
-60
lines changed

.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# editorconfig.org
2+
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
end_of_line = lf
8+
indent_size = 4
9+
indent_style = tab
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
13+
[**.{js,ts,jsx,tsx,less,css,sass,scss,json,yml,yaml}]
14+
indent_size = 2
15+
indent_style = space

.gitignore

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Numerous always-ignore extensions
2+
*.diff
3+
*.err
4+
*.orig
5+
*.log*
6+
*.rej
7+
*.swo
8+
*.swp
9+
*.zip
10+
*.vi
11+
*~
12+
*.lock
13+
!**/yarn.lock
14+
!**/composer.lock
15+
16+
# Dotenv
17+
.env
18+
.env.*
19+
!.env.example
20+
21+
# OS or Editor folders
22+
.DS_Store
23+
._*
24+
Thumbs.db
25+
.cache
26+
.project
27+
.settings
28+
.tmproj
29+
*.esproj
30+
nbproject
31+
*.sublime-project
32+
*.sublime-workspace
33+
.idea
34+
*.komodoproject
35+
.komodotools
36+
.atom
37+
.vscode
38+
.directory
39+
.sql

Dockerfile

+34-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,38 @@
11
FROM frolvlad/alpine-glibc:latest
22

3-
MAINTAINER Daniel Widerin <[email protected]>
3+
LABEL maintainer="Constantine Karnaukhov <[email protected]>"
44

5+
# Install dependencies
6+
ENV BUILD_DEPS='tar gzip' \
7+
RUN_DEPS='curl ca-certificates gettext'
8+
9+
RUN apk --no-cache add $BUILD_DEPS $RUN_DEPS
10+
11+
# Install kubectl
12+
ENV KUBECTL_VERSION=v1.11.3
13+
14+
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl && \
15+
chmod +x ./kubectl && \
16+
mv ./kubectl /usr/local/bin/
17+
18+
# Install OpenShift CLI
519
ENV OC_VERSION=v3.10.0 \
6-
OC_TAG_SHA=dd10d17 \
7-
BUILD_DEPS='tar gzip' \
8-
RUN_DEPS='curl ca-certificates gettext'
9-
10-
RUN apk --no-cache add $BUILD_DEPS $RUN_DEPS && \
11-
curl -sLo /tmp/oc.tar.gz https://github.com/openshift/origin/releases/download/${OC_VERSION}/openshift-origin-client-tools-${OC_VERSION}-${OC_TAG_SHA}-linux-64bit.tar.gz && \
12-
tar xzvf /tmp/oc.tar.gz -C /tmp/ && \
13-
mv /tmp/openshift-origin-client-tools-${OC_VERSION}-${OC_TAG_SHA}-linux-64bit/oc /usr/local/bin/ && \
14-
rm -rf /tmp/oc.tar.gz /tmp/openshift-origin-client-tools-${OC_VERSION}-${OC_TAG_SHA}-linux-64bit && \
15-
apk del $BUILD_DEPS
16-
17-
CMD ["/usr/local/bin/oc"]
20+
OC_TAG_SHA=dd10d17
21+
22+
RUN curl -sLo /tmp/oc.tar.gz https://github.com/openshift/origin/releases/download/${OC_VERSION}/openshift-origin-client-tools-${OC_VERSION}-${OC_TAG_SHA}-linux-64bit.tar.gz && \
23+
tar xzvf /tmp/oc.tar.gz -C /tmp/ && \
24+
mv /tmp/openshift-origin-client-tools-${OC_VERSION}-${OC_TAG_SHA}-linux-64bit/oc /usr/local/bin/ && \
25+
rm -rf /tmp/oc.tar.gz /tmp/openshift-origin-client-tools-${OC_VERSION}-${OC_TAG_SHA}-linux-64bit
26+
27+
# Install istioctl
28+
ENV ISTIO_VERSION=1.0.2
29+
30+
RUN curl -sLo /tmp/istio.tar.gz https://github.com/istio/istio/releases/download/${ISTIO_VERSION}/istio-${ISTIO_VERSION}-linux.tar.gz && \
31+
tar xzvf /tmp/istio.tar.gz -C /tmp/ && \
32+
mv /tmp/istio-${ISTIO_VERSION}/bin/istioctl /usr/local/bin/ && \
33+
rm -rf /tmp/istio.tar.gz /tmp/istio-${ISTIO_VERSION}
34+
35+
# Clean cache
36+
RUN apk del $BUILD_DEPS
37+
38+
CMD ["sh"]

README.md

+55-47
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
OpenShift CLI for CI/CD
2-
=======================
1+
# k8s-deploy-tools
32

4-
This [Openshift command line tool](https://docs.openshift.com/enterprise/3.0/cli_reference/get_started_cli.html) docker
5-
image ships `oc` and includes `gettext` so you can use `envsubst` to substitute
6-
environment variables in your CI/CD pipeline, for example using in
7-
[Jenkins](https://jenkins.io/) or a job in [GitLab CI .gitlab-ci.yml file](https://docs.gitlab.com/ce/ci/yaml/README.html#gitlab-ci-yml).
3+
CI/CD deployment tools for Kubernetes
84

9-
Examples
10-
--------
5+
## Docker Image
6+
7+
This alpine-based docker image contains next tools:
8+
9+
- [`kubectl`](https://kubernetes.io/docs/reference/kubectl/kubectl/) - Kubernetes CLI
10+
- [`oc`](https://docs.openshift.com/enterprise/3.0/cli_reference/get_started_cli.html) - OpenShift CLI
11+
- [`istioctl`](https://istio.io/docs/reference/commands/istioctl/) - Istio cli
12+
- `gettext` - so you can use `envsubst` to substitute environment variables in your CI/CD pipeline
13+
14+
## Examples
1115

1216
Why should I use `envsubst`? You should never put secrets into your version
1317
control, so you might want to keep them in secret variables in your CI/CD
@@ -21,49 +25,53 @@ Below I'll show an example of [GitLab CI variables set in the build environment]
2125

2226
Your `app.yaml` could look similar the one below:
2327

24-
$ cat app.yaml
25-
...
26-
- apiVersion: v1
27-
kind: DeploymentConfig
28-
metadata:
29-
labels:
30-
app: ${CI_PROJECT_NAME}
31-
name: sample
32-
spec:
33-
replicas: 1
34-
selector:
35-
app: ${CI_PROJECT_NAME}
36-
deployment: ${CI_BUILD_REF_SLUG}
37-
...
28+
```yaml
29+
...
30+
- apiVersion: v1
31+
kind: DeploymentConfig
32+
metadata:
33+
labels:
34+
app: ${CI_PROJECT_NAME}
35+
name: sample
36+
spec:
37+
replicas: 1
38+
selector:
39+
app: ${CI_PROJECT_NAME}
40+
deployment: ${CI_BUILD_REF_SLUG}
41+
...
42+
```
3843

3944
After `cat app.yaml | envsubst > app.yaml` you'll notice the variables have
4045
been replaced with their actual values:
4146

42-
$ cat app.yaml
43-
...
44-
- apiVersion: v1
45-
kind: DeploymentConfig
46-
metadata:
47-
labels:
48-
app: my_awesome_project
49-
name: sample
50-
spec:
51-
replicas: 1
52-
selector:
53-
app: my_awesome_project
54-
deployment: f1234d
55-
...
47+
```yaml
48+
...
49+
- apiVersion: v1
50+
kind: DeploymentConfig
51+
metadata:
52+
labels:
53+
app: my_awesome_project
54+
name: sample
55+
spec:
56+
replicas: 1
57+
selector:
58+
app: my_awesome_project
59+
deployment: f1234d
60+
...
61+
```
5662

57-
GitLab CI example
58-
-----------------
63+
## GitLab CI example
5964

60-
Below a sample job in an `.gitlab-ci.yml` file, please note that OpenShift does
61-
not allow `_` in project names:
65+
Below a sample job in an `.gitlab-ci.yml` file:
6266

63-
deploy:
64-
image: widerin/openshift-cli
65-
stage: deploy
66-
script:
67-
- oc login "$OPENSHIFT_SERVER" --token="$OPENSHIFT_TOKEN"
68-
- cat app.yaml | envsubst > app.yaml
69-
- oc replace -f app.yaml -n ${CI_PROJECT_NAME/_/}
67+
```yaml
68+
deploy:
69+
image: spaceonfire/k8s-deploy-tools
70+
stage: deploy
71+
before_script:
72+
- oc login "$KUBE_URL" --token="$KUBE_TOKEN" --insecure-skip-tls-verify
73+
- oc project "$KUBE_NAMESPACE" 2> /dev/null || oc new-project "$KUBE_NAMESPACE"
74+
script:
75+
- cat app.yaml | envsubst > app.yaml
76+
- oc apply -f app.yaml
77+
```

0 commit comments

Comments
 (0)