Skip to content
This repository was archived by the owner on Feb 11, 2025. It is now read-only.

Commit 8d733cd

Browse files
authored
Merge pull request #5 from fullstack-devops/feature/ansible-k8s
add ansible flavor + mod workflows
2 parents d13b63a + 1adfb39 commit 8d733cd

File tree

6 files changed

+127
-8
lines changed

6 files changed

+127
-8
lines changed

.github/workflows/build-pr.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,15 @@ jobs:
4646
push: true
4747
tags: |
4848
${{ env.IMAGE_BASE }}:kaniko-sidecar-pr-${{ github.event.pull_request.number }}
49+
50+
- name: link child image to current pr
51+
run: |
52+
sed -i --expression "s@FROM.*@FROM ${{ env.IMAGE_BASE }}:base-pr-${{ github.event.pull_request.number }}@g" images/ansible-k8s/Dockerfile
53+
54+
- name: Build github-actions-runner:ansible-k8s
55+
uses: docker/build-push-action@v2
56+
with:
57+
context: ./images/ansible-k8s
58+
push: true
59+
tags: |
60+
${{ env.IMAGE_BASE }}:ansible-k8s-pr-${{ github.event.pull_request.number }}

.github/workflows/cleanup-pr.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,23 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Delete base image
13-
uses: bots-house/ghcr-delete-image-action@v1
13+
uses: bots-house/ghcr-delete-image-action@v1.0.0
1414
with:
1515
owner: ${{ github.repository_owner }}
1616
name: github-actions-runner
1717
token: ${{ secrets.GITHUB_TOKEN }}
1818
tag: base-pr-${{ github.event.pull_request.number }}
1919
- name: Delete kaniko-sidecar image
20-
uses: bots-house/ghcr-delete-image-action@v1
20+
uses: bots-house/ghcr-delete-image-action@v1.0.0
2121
with:
2222
owner: ${{ github.repository_owner }}
2323
name: github-actions-runner
2424
token: ${{ secrets.GITHUB_TOKEN }}
25-
tag: kaniko-sidecar-pr-${{ github.event.pull_request.number }}
25+
tag: kaniko-sidecar-pr-${{ github.event.pull_request.number }}
26+
- name: Delete kaniko-sidecar image
27+
uses: bots-house/[email protected]
28+
with:
29+
owner: ${{ github.repository_owner }}
30+
name: github-actions-runner
31+
token: ${{ secrets.GITHUB_TOKEN }}
32+
tag: ansible-k8s-pr-${{ github.event.pull_request.number }}

.github/workflows/create-release.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,31 @@ jobs:
4343
context: ./images/base
4444
push: true
4545
tags: |
46-
${IMAGE_BASE}:latest
47-
${IMAGE_BASE}:base-latest
48-
${IMAGE_BASE}:base-${{needs.create_release.outputs.version}}
46+
${{ env.IMAGE_BASE }}:latest
47+
${{ env.IMAGE_BASE }}:base-latest
48+
${{ env.IMAGE_BASE }}:base-${{needs.create_release.outputs.version}}
4949
5050
- name: Build github-actions-runner:kaniko-sidecar
5151
uses: docker/build-push-action@v2
5252
with:
5353
context: ./images/kaniko-sidecar
5454
push: true
5555
tags: |
56-
${IMAGE_BASE}:kaniko-sidecar-${{needs.create_release.outputs.version}}
56+
${{ env.IMAGE_BASE }}:kaniko-sidecar-latest
57+
${{ env.IMAGE_BASE }}:kaniko-sidecar-${{needs.create_release.outputs.version}}
58+
59+
- name: link child image to current version
60+
run: |
61+
sed -i --expression "s@FROM.*@FROM ${{ env.IMAGE_BASE }}:base-${{ needs.create_release.outputs.version }}@g" images/ansible-k8s/Dockerfile
62+
63+
- name: Build github-actions-runner:ansible-k8s
64+
uses: docker/build-push-action@v2
65+
with:
66+
context: ./images/ansible-k8s
67+
push: true
68+
tags: |
69+
${{ env.IMAGE_BASE }}:ansible-k8s-latest
70+
${{ env.IMAGE_BASE }}:ansible-k8s-${{needs.create_release.outputs.version}}
5771
5872
publish_release:
5973
runs-on: ubuntu-latest

README.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# github-runner-base
22
Base Image for github runner images in repo @fullstack-devops/github-runner. Can also be used as standalone image.
33

4+
Available Containers:
5+
| Name | Description |
6+
|------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------|
7+
| `ghcr.io/fullstack-devops/github-actions-runner:base-latest` | Base runner with nothing fancy installed |
8+
| `ghcr.io/fullstack-devops/github-actions-runner:kaniko-sidecar-latest` | Sidecar used by Runner to build containers without root privileges |
9+
| `ghcr.io/fullstack-devops/github-actions-runner:ansible-k8s-latest` | Rrunner with ansible, kubectl and helm installed <br> For more Details see [Dockerfile](images/ansible-k8s/Dockerfile) |
10+
411
---
512

613
## Environmental variables
@@ -82,7 +89,33 @@ services:
8289
8390
### kubernetes pod
8491
85-
tbd
92+
```yaml
93+
apiVersion: v1
94+
kind: Pod
95+
metadata:
96+
name: gha-runner-kaniko
97+
spec:
98+
volumes:
99+
- name: workspace-volume
100+
emptyDir: {}
101+
containers:
102+
- name: github-actions-runner
103+
image: ghcr.io/fullstack-devops/github-actions-runner:base-latest
104+
resources: {}
105+
volumeMounts:
106+
- name: workspace-volume
107+
mountPath: /kaniko/workspace/
108+
imagePullPolicy: Never
109+
tty: true
110+
- name: kaniko-sidecar
111+
image: ghcr.io/fullstack-devops/github-actions-runner:kaniko-sidecar-latest
112+
resources: {}
113+
volumeMounts:
114+
- name: workspace-volume
115+
mountPath: /kaniko/workspace/
116+
imagePullPolicy: Never
117+
restartPolicy: Never
118+
```
86119
87120
### helm
88121

images/ansible-k8s/Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
FROM ghcr.io/fullstack-devops/github-actions-runner:base-latest
2+
3+
USER root
4+
# install packages along with jq so we can parse JSON
5+
# add additional packages as necessary
6+
ARG PACKAGES="ansible"
7+
8+
RUN apt-get update \
9+
&& apt-get install -y --no-install-recommends ${PACKAGES} \
10+
&& rm -rf /var/lib/apt/lists/* \
11+
&& apt-get clean
12+
13+
ENV GH_RUNNER_LABELS="ubuntu-20.04,ansible-k8s"
14+
ARG KUBECTL_VERSION=1.21.0
15+
ARG HELM_VERSION=3.6.3
16+
17+
# Install kubectl
18+
RUN wget -q https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl -O /usr/local/bin/kubectl \
19+
&& chmod +x /usr/local/bin/kubectl
20+
21+
# Install helm
22+
RUN wget -q https://get.helm.sh/helm-v${HELM_VERSION}-linux-amd64.tar.gz -O - | tar -xzO linux-amd64/helm > /usr/local/bin/helm \
23+
&& chmod +x /usr/local/bin/helm
24+
25+
ENV TMP_DIR=/home/${USERNAME}/tmp
26+
27+
RUN mkdir /home/${USERNAME}/.ansible
28+
RUN mkdir ${TMP_DIR}
29+
30+
COPY requirements.yml ${TMP_DIR}/requirements.yml
31+
32+
RUN chown -R ${USERNAME} /home/${USERNAME}
33+
34+
USER ${USERNAME}
35+
36+
RUN ansible-galaxy install -c -r ${TMP_DIR}/requirements.yml
37+
RUN ansible-galaxy collection install -c -r ${TMP_DIR}/requirements.yml
38+
39+
# install helm plugins helm push, appr && diff
40+
RUN helm plugin install --version 0.10.2 https://github.com/chartmuseum/helm-push.git \
41+
&& helm plugin install --version 0.7.0 https://github.com/app-registry/appr-helm-plugin.git \
42+
&& helm plugin install --version 3.4.2 https://github.com/databus23/helm-diff

images/ansible-k8s/requirements.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
roles:
3+
- name: geerlingguy.helm
4+
version: 1.0.0
5+
6+
collections:
7+
- name: kubernetes.core
8+
version: 1.2.0
9+
10+
- name: community.kubernetes
11+
version: 1.0.0

0 commit comments

Comments
 (0)