Skip to content

Commit 47de5c8

Browse files
authored
Feature/Migrate container images (#4)
* Skip helm chart release packaging if exists * Use correct Helm repo URL * Add Helm charts: NFS-Ganesha & Rancher Cluster Template * Copy demo application source * Update CI to build and scan images * Bump Helm charts & fix bad EOL * Add Dockerhub login * Update PKG with container image creation
1 parent c2c53cc commit 47de5c8

File tree

226 files changed

+21995
-19
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

226 files changed

+21995
-19
lines changed

.github/workflows/ci.yml

+51-1
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,29 @@ concurrency:
1616
group: "${{ github.ref }}-${{ github.workflow }}"
1717
cancel-in-progress: true
1818

19+
permissions:
20+
contents: read
21+
pull-requests: write
22+
1923
jobs:
24+
changes:
25+
runs-on: ubuntu-latest
26+
permissions:
27+
pull-requests: read
28+
outputs:
29+
apps: ${{ steps.filter.outputs.changes }}
30+
steps:
31+
- uses: dorny/paths-filter@v3
32+
id: filter
33+
with:
34+
filters: |
35+
game-2048: src/game-2048/**
36+
cow-demo: src/cow-demo/**
37+
rancher-helloworld: src/rancher-helloworld/**
2038
code-check:
2139
runs-on: ubuntu-latest
2240
steps:
23-
- name: Check-out the repository
41+
- name: Checkout source code
2442
uses: actions/checkout@v4
2543
with:
2644
# gets all history for all branches and tags (mandatory for chart-testing to work, see https://github.com/helm/chart-testing/issues/186)
@@ -60,3 +78,35 @@ jobs:
6078
- name: Run chart-testing (lint)
6179
if: steps.list-changed.outputs.changed == 'true'
6280
run: ct lint --target-branch ${{ github.event.repository.default_branch }}
81+
image-scan:
82+
needs: changes
83+
if: needs.changes.outputs.apps != '[]'
84+
strategy:
85+
matrix:
86+
app: ${{ fromJSON(needs.changes.outputs.apps) }}
87+
runs-on: ubuntu-latest
88+
steps:
89+
- name: Checkout source code
90+
uses: actions/checkout@v4
91+
- name: Login to Docker Hub
92+
uses: docker/login-action@v3
93+
with:
94+
username: ${{ secrets.DOCKERHUB_USERNAME }}
95+
password: ${{ secrets.DOCKERHUB_TOKEN }}
96+
- name: Build container image from source
97+
run: |
98+
cd src/${{ matrix.app }}
99+
docker build . --tag $CONTAINER_REGITRY_DOMAIN/$IMAGE_FOLDER/${{ matrix.app }}:${{ env.IMAGE_TAG }}
100+
- name: Scan container image with NeuVector
101+
if: ${{ vars.USE_NEUVECTOR == 'true' }}
102+
uses: neuvector/scan-action@main
103+
with:
104+
image-repository: ${{ env.CONTAINER_REGITRY_DOMAIN }}/${{ env.IMAGE_FOLDER }}/${{ matrix.app }}
105+
image-tag: ${{ env.IMAGE_TAG }}
106+
min-high-cves-to-fail: "1"
107+
min-medium-cves-to-fail: "1"
108+
env:
109+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
110+
CONTAINER_REGITRY_DOMAIN: docker.io
111+
IMAGE_FOLDER: ${{ vars.DOCKERHUB_NAMESPACE }}
112+
IMAGE_TAG: 1.0.${{ github.run_id }}

.github/workflows/pkg.yml

+46
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ permissions:
1111
id-token: write
1212

1313
jobs:
14+
changes:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
pull-requests: read
18+
outputs:
19+
apps: ${{ steps.filter.outputs.changes }}
20+
steps:
21+
- uses: dorny/paths-filter@v3
22+
id: filter
23+
with:
24+
filters: |
25+
game-2048: src/game-2048/**
26+
cow-demo: src/cow-demo/**
27+
rancher-helloworld: src/rancher-helloworld/**
1428
build:
1529
runs-on: ubuntu-latest
1630
steps:
@@ -32,6 +46,8 @@ jobs:
3246
helm repo update
3347
- name: Host charts repository on GitHub Pages
3448
uses: helm/[email protected]
49+
with:
50+
skip_existing: true
3551
env:
3652
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
3753
- name: Checkout gh-pages branch
@@ -63,3 +79,33 @@ jobs:
6379
- name: Deploy to GitHub Pages
6480
id: deployment
6581
uses: actions/deploy-pages@v1
82+
create-image:
83+
if: needs.changes.outputs.apps != '[]'
84+
strategy:
85+
matrix:
86+
app: ${{ fromJSON(needs.changes.outputs.apps) }}
87+
runs-on: ubuntu-latest
88+
steps:
89+
- name: Checkout source code
90+
uses: actions/checkout@v4
91+
- name: Login to container registry
92+
uses: docker/login-action@v3
93+
with:
94+
registry: ${{ env.CONTAINER_REGITRY_DOMAIN }}
95+
username: ${{ secrets.DOCKERHUB_USERNAME }}
96+
password: ${{ secrets.DOCKERHUB_TOKEN }}
97+
- name: Build container image
98+
run: |
99+
cd src/${{ matrix.app }}
100+
docker build . --tag $IMAGE_FOLDER/${{ matrix.app }}:${{ env.IMAGE_TAG }}
101+
- name: Push image to container registry
102+
run: docker push $IMAGE_FOLDER/${{ matrix.app }}:${{ env.IMAGE_TAG }}
103+
- name: Push latest tag to container registry
104+
if: ${{ github.ref_name == 'main' }}
105+
run: |
106+
docker tag $IMAGE_FOLDER/${{ matrix.app }}:${{ env.IMAGE_TAG }} $IMAGE_FOLDER/${{ matrix.app }}:latest
107+
docker push $IMAGE_FOLDER/${{ matrix.app }}:latest
108+
env:
109+
CONTAINER_REGITRY_DOMAIN: docker.io
110+
IMAGE_FOLDER: ${{ vars.DOCKERHUB_NAMESPACE }}
111+
IMAGE_TAG: 1.0.${GITHUB_RUN_ID}

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
temp*.yaml
66
temp.sh
77
/charts/temp/
8-
values_*.y*ml
8+
values_mine.y*ml
9+
.sass-cache/

CONTRIBUTING.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Contribution guide
2+
3+
## Code lifecycle
4+
5+
This git repository follows the Gitflow pattern, so make sure to follow the convention.
6+
7+
For instance, create a branch `feature/my-change-title` from `develop`, once good enough to be shared and reviewed create a Pull Request targetting `develop`.
8+
9+
## Code convention
10+
11+
For bash/shell script files, follow the conventions from [Google Style Guide](https://google.github.io/styleguide/shellguide.html).

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Welcome! You'll find in this repository some open-source material to setup a lab environment.
66

7-
It is used internally at SUSE (the goal being to capitalize and factorize), but is open to everyone. Feel free to contribute and share feedback!
7+
It is used internally at SUSE but is open to everyone. Feel free to [contribute](CONTRIBUTING.md) and share feedback!
88

99
## Getting started
1010

@@ -32,7 +32,7 @@ Browse the [catalog of functions](scripts/README.md#shell-functions) and [concre
3232
Add Helm repository:
3333

3434
```bash
35-
helm repo add suse-lab-setup https://suse.github.io/lab-setup
35+
helm repo add suse-lab-setup https://opensource.suse.com/lab-setup
3636
helm repo update
3737
```
3838

charts/README.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,23 @@
55
* [Cow Demo](cow-demo/README.md)
66
* [Game 2048](game-2048/README.md)
77
* [Let's Encrypt](letsencrypt/README.md)
8+
* [NFS-Ganesha](nfs-ganesha/README.md)
9+
* [Rancher Cluster Template](rancher-cluster-templates/README.md)
810
* [WordPress](wordpress/README.md)
911

1012
## Developer's guide
1113

14+
From within a chart directory:
15+
1216
```bash
1317
# lints a chart
14-
helm lint .
18+
helm lint
19+
20+
# generates the manifest file from a chart (for review/comparison)
21+
helm template <releasename> . -f values.yaml -f values_mine.yaml --namespace demo > temp.yaml
1522

16-
# creates Kubernetes template file from chart (for review/comparison)
17-
helm template myname . -f values.yaml --namespace demo > temp.yaml
23+
# installs a chart from local source
24+
helm upgrade --install <releasename> . -f values.yaml \
25+
# --debug > output.yaml \
26+
--create-namespace --namespace nfs-ganesha
1827
```

charts/cow-demo/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: cow-demo
33
description: Helm chart for Cow Demo Application
44
type: application
5-
version: 0.1.0
5+
version: 0.1.1
66
appVersion: "2.0.0"
77
home: https://github.com/SUSE/lab-setup/tree/main/charts/cow-demo
88
maintainers:

charts/cow-demo/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ Install the app with default settings:
88

99
```bash
1010
# adds the repo
11-
helm repo add devpro https://devpro.github.io/helm-charts
11+
helm repo add suse-lab-setup https://opensource.suse.com/lab-setup
1212
helm repo update
1313

1414
# installs the chart
15-
helm upgrade --install cow-demo devpro/cow-demo --namespace demo --create-namespace
15+
helm upgrade --install cow-demo suse-lab-setup/cow-demo --namespace demo --create-namespace
1616
```
1717

1818
Look at [values.yaml](values.yaml) for the configuration.

charts/game-2048/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: game-2048
33
description: Helm chart for Game 2048
44
type: application
5-
version: 0.1.0
5+
version: 0.1.1
66
appVersion: "1.0.0"
77
home: https://github.com/SUSE/lab-setup/tree/main/charts/game-2048
88
maintainers:

charts/game-2048/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ Install the app with default settings:
88

99
```bash
1010
# adds the repo
11-
helm repo add devpro https://devpro.github.io/helm-charts
11+
helm repo add suse-lab-setup https://opensource.suse.com/lab-setup
1212
helm repo update
1313

1414
# installs the chart
15-
helm upgrade --install game-2048 devpro/game-2048 --namespace demo --create-namespace
15+
helm upgrade --install game-2048 suse-lab-setup/game-2048 --namespace demo --create-namespace
1616
```
1717

1818
Look at [values.yaml](values.yaml) for the configuration.

charts/letsencrypt/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: letsencrypt
33
description: Helm chart for managing Let's Encrypt
44
type: application
5-
version: 0.1.0
5+
version: 0.1.1
66
appVersion: "1.0.0"
77
home: https://github.com/SUSE/lab-setup/tree/main/charts/letsencrypt
88
maintainers:

charts/letsencrypt/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ Install the app with minimal settings:
1010

1111
```bash
1212
# adds the repo
13-
helm repo add devpro https://devpro.github.io/helm-charts
13+
helm repo add suse-lab-setup https://opensource.suse.com/lab-setup
1414
helm repo update
1515

1616
# installs the chart (this examples assumes NGINX Ingress Controller is installed)
17-
helm upgrade --install letsencrypt devpro/letsencrypt \
17+
helm upgrade --install letsencrypt suse-lab-setup/letsencrypt \
1818
--namespace cert-manager \
1919
2020
--set ingress.className=nginx

charts/nfs-ganesha/.helmignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

charts/nfs-ganesha/Chart.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v2
2+
name: nfs-ganesha
3+
description: Helm chart for managing NFS-Ganesha
4+
type: application
5+
version: "0.1.0"
6+
appVersion: "1.0.0"
7+
dependencies: []
8+
home: https://github.com/SUSE/lab-setup/tree/main/charts/nfs-ganesha
9+
maintainers:
10+
- name: devpro
11+

charts/nfs-ganesha/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# NFS-Ganesha Helm Chart
2+
3+
This Helm chart will install [NFS-Ganesha](https://nfs-ganesha.github.io/) on a Kubernetes cluster.
4+
5+
## Quick start
6+
7+
Install the app with minimal settings:
8+
9+
```bash
10+
# adds the repo
11+
helm repo add suse-lab-setup https://opensource.suse.com/lab-setup
12+
helm repo update
13+
14+
# installs the chart with default parameters
15+
helm upgrade --install nfs-ganesha suse-lab-setup/nfs-ganesha --create-namespace --namespace nfs-ganesha
16+
```
17+
18+
Clean-up:
19+
20+
```bash
21+
helm delete nfs-ganesha -n nfs-ganesha
22+
kubectl delete ns nfs-ganesha
23+
```

charts/nfs-ganesha/templates/NOTES.txt

Whitespace-only changes.

charts/nfs-ganesha/templates/_helpers.tpl

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
labels:
6+
app: {{ .Values.name }}
7+
name: {{ .Values.name }}
8+
spec:
9+
replicas: 1
10+
selector:
11+
matchLabels:
12+
app: {{ .Values.name }}
13+
template:
14+
metadata:
15+
labels:
16+
app: nfs-ganesha
17+
spec:
18+
containers:
19+
- name: container-0
20+
image: {{ .Values.image }}:{{ .Values.tag }}
21+
imagePullPolicy: Always
22+
ports:
23+
- containerPort: 2049
24+
name: nfsv4
25+
protocol: TCP
26+
securityContext:
27+
capabilities:
28+
add:
29+
- NET_ADMIN
30+
- DAC_READ_SEARCH
31+
privileged: true
32+
volumeMounts:
33+
- mountPath: /data/nfs
34+
name: share
35+
dnsPolicy: ClusterFirst
36+
restartPolicy: Always
37+
volumes:
38+
- emptyDir: {}
39+
name: share
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: {{ .Values.name }}-nodeport
6+
spec:
7+
selector:
8+
app: {{ .Values.name }}
9+
type: NodePort
10+
ports:
11+
- name: nfsv4
12+
nodePort: 32049
13+
port: 2049
14+
protocol: TCP
15+
targetPort: 2049
16+
---
17+
apiVersion: v1
18+
kind: Service
19+
metadata:
20+
name: {{ .Values.name }}
21+
spec:
22+
selector:
23+
app: {{ .Values.name }}
24+
type: ClusterIP
25+
ports:
26+
- name: nfsv4
27+
port: 2049
28+
protocol: TCP
29+
targetPort: 2049

charts/nfs-ganesha/values.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: nfs-ganesha
2+
image: janeczku/nfs-ganesha
3+
tag: latest

0 commit comments

Comments
 (0)