Skip to content

Commit c7bae7b

Browse files
authored
Merge pull request #69 from jency92/main
helm chart for scsctl controller
2 parents 65ce29c + 9e5ee34 commit c7bae7b

15 files changed

+652
-0
lines changed

.github/workflows/container-pr.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: scsctl Container image build for PR
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- 'main'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
env:
12+
REGISTRY: ghcr.io
13+
GH_URL: https://github.com
14+
steps:
15+
-
16+
name: Checkout
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
21+
-
22+
name: Set up QEMU
23+
uses: docker/setup-qemu-action@v2
24+
25+
- uses: docker/setup-buildx-action@v1
26+
name: Set up Docker Buildx
27+
28+
-
29+
name: Login to ghcr registry
30+
uses: docker/login-action@v2
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
37+
-
38+
name: Build and push on PR
39+
uses: docker/build-push-action@v4
40+
if: github.event_name == 'pull_request'
41+
with:
42+
context: .
43+
file: ./Dockerfile
44+
push: true
45+
tags: ${{ env.REGISTRY }}/${{ github.repository }}${{ github.event.pull_request.number }}
46+
build-args: |
47+
"GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}"
48+
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: scsctl container image release
2+
on:
3+
push:
4+
tags:
5+
- "v*.*.*"
6+
jobs:
7+
push_to_registry:
8+
name: Build and push Docker image github container registry.
9+
runs-on: ubuntu-20.04
10+
permissions:
11+
packages: write
12+
id-token: write
13+
contents: read
14+
actions: read
15+
security-events: write
16+
env:
17+
REGISTRY: ghcr.io
18+
GH_URL: https://github.com
19+
steps:
20+
- name: Set environment variable
21+
run: |
22+
echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV
23+
- name: Test environment variable
24+
run: echo ${{ env.RELEASE_VERSION }}
25+
- name: Check out GitHub repo
26+
uses: actions/checkout@v3
27+
- name: Login to GitHub Container Registry
28+
uses: docker/login-action@v2
29+
with:
30+
registry: ${{ env.REGISTRY }}
31+
username: ${{ github.actor }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
- name: Build image and push to GitHub Container Registry
34+
uses: docker/build-push-action@v4
35+
with:
36+
push: true
37+
context: ./
38+
file: ./Dockerfile
39+
tags: ${{ env.REGISTRY }}/${{ github.repository }}:${{ env.RELEASE_VERSION }}
40+
- name: Install cosign
41+
uses: sigstore/cosign-installer@main
42+
- name: Sign the images
43+
run: |
44+
cosign sign -y ${{ env.REGISTRY }}/${{ github.repository }}:${{ env.RELEASE_VERSION }}
45+
env:
46+
COSIGN_EXPERIMENTAL: 1
47+
- name: Verify the pushed tags
48+
run: cosign verify ${{ env.REGISTRY }}/${{ github.repository }}:${{ env.RELEASE_VERSION }} --certificate-identity ${{ env.GH_URL }}/${{ github.repository }}/.github/workflows/container-release.yml@refs/tags/${{ env.RELEASE_VERSION }} --certificate-oidc-issuer https://token.actions.githubusercontent.com
49+
env:
50+
COSIGN_EXPERIMENTAL: 1
51+
- name: Run Trivy in GitHub SBOM mode and submit results to Dependency Graph
52+
uses: aquasecurity/trivy-action@master
53+
with:
54+
scan-type: 'fs'
55+
format: 'github'
56+
output: 'dependency-results.sbom.json'
57+
image-ref: '.'
58+
github-pat: ${{ secrets.GITHUB_TOKEN }} # or ${{ secrets.github_pat_name }} if you're using a PAT

.github/workflows/container.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Container Docker Image CI
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- '**.md'
7+
- 'charts/**'
8+
branches:
9+
- 'main'
10+
11+
jobs:
12+
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
permissions:
17+
packages: write
18+
id-token: write
19+
contents: read
20+
actions: read
21+
security-events: write
22+
env:
23+
REGISTRY: ghcr.io
24+
GH_URL: https://github.com
25+
steps:
26+
- name: Checkout GitHub Action
27+
uses: actions/checkout@v3
28+
29+
- name: Set up Docker Buildx
30+
id: buildx
31+
uses: docker/setup-buildx-action@v2
32+
33+
- name: Docker metadata
34+
id: metadata
35+
uses: docker/metadata-action@v4
36+
with:
37+
images: ${{ env.REGISTRY }}/${{ github.repository }}
38+
tags: |
39+
type=semver,pattern={{version}}
40+
type=semver,pattern={{major}}.{{minor}}
41+
type=raw,value={{sha}},enable=${{ github.ref_type != 'tag' }}
42+
flavor: |
43+
latest=true
44+
45+
- name: Login to GitHub Container Registry
46+
uses: docker/login-action@v2
47+
with:
48+
registry: ${{ env.REGISTRY }}
49+
username: ${{ github.actor }}
50+
password: ${{ secrets.GITHUB_TOKEN }}
51+
52+
- name: Build image and push to GitHub Container Registry
53+
uses: docker/build-push-action@v4
54+
with:
55+
context: .
56+
file: ./Dockerfile
57+
tags: ${{ env.REGISTRY }}/${{ github.repository }}:${{ github.run_id }}
58+
labels: ${{ steps.metadata.outputs.labels }}
59+
60+
push: true
61+
62+
- name: Install cosign
63+
uses: sigstore/cosign-installer@main
64+
65+
- name: Sign the images
66+
run: |
67+
cosign sign -y ${{ env.REGISTRY }}/${{ github.repository }}:${{ github.run_id }}
68+
env:
69+
COSIGN_EXPERIMENTAL: 1
70+
71+
- name: Verify the pushed tags
72+
run: cosign verify ${{ env.REGISTRY }}/${{ github.repository }}:${{ github.run_id }} --certificate-identity ${{ env.GH_URL }}/${{ github.repository }}/.github/workflows/container.yml@refs/heads/main --certificate-oidc-issuer https://token.actions.githubusercontent.com
73+
env:
74+
COSIGN_EXPERIMENTAL: 1
75+
76+
- name: Run Trivy in GitHub SBOM mode and submit results to Dependency Graph
77+
uses: aquasecurity/trivy-action@master
78+
with:
79+
scan-type: 'fs'
80+
format: 'github'
81+
output: 'dependency-results.sbom.json'
82+
image-ref: '.'
83+
github-pat: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/helm_release.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Helm Chart publish
2+
3+
on:
4+
push:
5+
paths:
6+
- 'charts/**'
7+
branches:
8+
- main
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Configure Git
19+
run: |
20+
git config user.name "$GITHUB_ACTOR"
21+
git config user.email "$GITHUB_ACTOR@@gmail.com"
22+
23+
- name: Run chart-releaser
24+
uses: helm/[email protected]
25+
env:
26+
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

charts/.helmignore

Lines changed: 23 additions & 0 deletions
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/scsctl/Chart.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: scsctl
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "1.16.0"

charts/scsctl/templates/NOTES.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.service.type }}
9+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "scsctl.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11+
echo http://$NODE_IP:$NODE_PORT
12+
{{- else if contains "LoadBalancer" .Values.service.type }}
13+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14+
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "scsctl.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "scsctl.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
16+
echo http://$SERVICE_IP:{{ .Values.service.port }}
17+
{{- else if contains "ClusterIP" .Values.service.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "scsctl.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
20+
echo "Visit http://127.0.0.1:8080 to use your application"
21+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
22+
{{- end }}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "scsctl.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "scsctl.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "scsctl.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "scsctl.labels" -}}
37+
helm.sh/chart: {{ include "scsctl.chart" . }}
38+
{{ include "scsctl.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "scsctl.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "scsctl.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "scsctl.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "scsctl.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}

0 commit comments

Comments
 (0)