Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
pehbehbeh committed May 13, 2019
2 parents 505e089 + 3bc7b37 commit 1a86808
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
14 changes: 9 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
FROM rancher/cli:v2.0.4

# install dependencies
RUN apk add --no-cache curl
RUN apk update \
&& apk add --no-cache \
ca-certificates \
curl

# install kubectl
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.12.0/bin/linux/amd64/kubectl \
&& chmod +x ./kubectl \
&& mv ./kubectl /usr/local/bin/kubectl

# add rancher-redeploy script
COPY bin/rancher-redeploy /usr/local/bin/
RUN chmod +x /usr/local/bin/rancher-redeploy
# add helper scripts
COPY bin/ /usr/local/bin/

## make all binaries executable
RUN chmod +x /usr/local/bin/*

# reset entrypoint
ENTRYPOINT []
10 changes: 8 additions & 2 deletions readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ This docker image enables simple deployments to Rancher.
It is a small alpine image with [Rancher CLI](https://rancher.com/docs/rancher/v2.x/en/cli/) `rancher`
and [Kubernetes CLI](https://kubernetes.io/docs/tasks/tools/install-kubectl/) `kubectl` installed.

It also comes with a custom `rancher-redeploy` command (see usage section).
It also comes with a custom `rancher-redeploy` and `rancher-exec` command helper (see usage section).

## Usage

### Simple Redeploy via GitLab CI
### Simple Redeploy via GitLab CI and `rancher-redeploy` helper

To use this image via GitLab CI add the following to the `.gitlab-ci.yml`:

Expand All @@ -36,6 +36,12 @@ Don't forget to provide `$RANCHER_TOKEN` via GitLab CI/CD variable.
This will trigger a redeploy of the given Kubernetes deployment by updating a label
and pull the newest image if configured correctly.

### Execute Command via `rancher-exec` helper

You can also execute commands in pods of your deployment via `rancher-exec $K8S_NAMESPACE $K8S_DEPLOYMENT 'ls'`.
This will execute the given command in the first pod of your deployment.
Currently this is only tested with single container pods.

## Changelog

Check [releases](https://github.com/sourceboat/rancher-deploy/releases) for all notable changes.
Expand Down
4 changes: 4 additions & 0 deletions bin/rancher-exec
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
POD=$(rancher kubectl get pod -l workload.user.cattle.io/workloadselector=deployment-$1-$2 -n $1 -o jsonpath="{.items[0].metadata.name}")
echo "INFO: executing '$3' in pod '$POD'\n"
rancher kubectl exec $POD -n $1 $3

0 comments on commit 1a86808

Please sign in to comment.