Skip to content

Commit

Permalink
Merge branch 'main' into better-test-coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ciroque authored Dec 18, 2023
2 parents 07d1368 + 2ee0441 commit bd31460
Show file tree
Hide file tree
Showing 67 changed files with 3,359 additions and 64 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text eol=lf

*.png binary
10 changes: 5 additions & 5 deletions .github/workflows/build-and-sign-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: actions/checkout@v4

- name: Install cosign
uses: sigstore/cosign-installer@11086d25041f77fe8fe7b9ea4e48e3b9192b8f19 #v3.0.2
uses: sigstore/cosign-installer@1fc5bd396d372bee37d608f955b336615edf79c8 #v3.0.2
with:
cosign-release: 'v1.13.1'

Expand All @@ -41,13 +41,13 @@ jobs:

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934
uses: docker/metadata-action@31cebacef4805868f9ce9a0cb03ee36c32df2ac4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build Docker Image
id: docker-build-and-push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
with:
context: .
file: ./Dockerfile
Expand All @@ -64,7 +64,7 @@ jobs:
# NOTE: This runs statically against the latest tag in Docker Hub which was not produced by this workflow
# This should be updated once this workflow is fully implemented
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@fbd16365eb88e12433951383f5e99bd901fc618f # 0.12.0
uses: aquasecurity/trivy-action@91713af97dc80187565512baba96e4364e983601 # 0.16.0
continue-on-error: true
with:
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
Expand All @@ -73,7 +73,7 @@ jobs:
ignore-unfixed: 'true'

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@0116bc2df50751f9724a2e35ef1f24d22f90e4e1 # v2.2.11
uses: github/codeql-action/upload-sarif@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.2.11
continue-on-error: true
with:
sarif_file: 'trivy-results-${{ inputs.image }}.sarif'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.19

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@483ef80eb98fb506c348f7d62e28055e49fe2398 # v2.3.0
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
with:
results_file: results.sarif
results_format: sarif
Expand Down Expand Up @@ -68,5 +68,6 @@ jobs:
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@0116bc2df50751f9724a2e35ef1f24d22f90e4e1 # v2.22.3
uses: github/codeql-action/upload-sarif@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.22.8
with:
sarif_file: results.sarif
8 changes: 2 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ Thumbs.db
*.log
/misc-dev/

cover.html
cover.out
tmp/

cover.out
cover.html
cover*
tmp/
docs/tls/DESIGN.md
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
golang 1.19.13
10 changes: 10 additions & 0 deletions ca-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
data:
tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURUekNDQWpjQ0ZGNGlKWWxnWFYrNksx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3Nk52SWx4RXQzTHhseGxadlkzdjhmdXpFRUdqd3l0Zkk2c2krVzd4eGNYVmRmY1pIWHp0RXR5TXo2WnoxMHgKcTZjaEQ2OWMwQXlPYzdOV1g2dDNnQk5vVkZFOTBiT1cyZWpDY1M0TFNYaEVwRTNITzdpKytOa1BBb0dBZW9CYgo1Sk9TbXVvOG9GZTNVMlNpaHArOUhVZy9iRE9IamZWSE1zSTUreUIwN3h5YUpCcHJNVzdTYXV6OUJ5OWxqSjhjCm05M3FWUy94OFZFNVUzNTNsV2hWeGovQ3NOQ1JTek9oaXZvNktvV0g2N3FSTjJKcVorNjE0MUtITkxpZGY0R0MKZXVONURiV1dqNzVjL2tIWUtyTW1xVVRvTGE3T3FFeHpiRmFCUnMwQ2dZQUN6UlBiQTBqK0JyOWpxenFKYU56VQpPZzJ4aUFhZlNuTzBxTkREZWZNdXhZSnFMZ0llMG9HRUExb1JlcDhvTDNDeWZYd2h3U2xqMlRjeGZZTFR5MENKCmZBejF4QjY3SUF3cGlvZnI0K1ZXekF4SC9BbnlhVGNZVGdtakdKdlhtZ3l1RGU3ZGJsa3lJU1M5ZTBLc1JzeTYKQ2hPdVZoQy96bjErbm9BMkNsdzFJdz09Ci0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K
kind: Secret
metadata:
creationTimestamp: null
name: nlk-tls-ca-secret
namespace: nlk
type: kubernetes.io/tls
2 changes: 2 additions & 0 deletions charts/nlk/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Patterns to ignore when building packages.
.png
19 changes: 19 additions & 0 deletions charts/nlk/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
apiVersion: v2
appVersion: 0.1.0
description: NGINX LoadBalancer for Kubernetes
name: nginx-loadbalancer-kubernetes
home: https://github.com/nginxinc/nginx-loadbalancer-kubernetes
icon: https://raw.githubusercontent.com/nginxinc/nginx-loadbalancer-kubernetes/main/nlk-logo.svg
keywords:
- nginx
- loadbalancer
- ingress
kubeVersion: '>= 1.22.0-0'
maintainers:
- name: "@ciroque"
- name: "@chrisakker"
- name: "@abdennour"

type: application
version: 0.0.1
110 changes: 110 additions & 0 deletions charts/nlk/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{{/* vim: set filetype=mustache: */}}

{{/*
Expand the name of the chart.
*/}}
{{- define "nlk.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "nlk.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create a default fully qualified nlk name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "nlk.nlk.fullname" -}}
{{- printf "%s-%s" (include "nlk.fullname" .) .Values.nlk.name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified nlk service name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "nlk.nlk.service.name" -}}
{{- default (include "nlk.nlk.fullname" .) .Values.serviceNameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "nlk.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "nlk.labels" -}}
helm.sh/chart: {{ include "nlk.chart" . }}
{{ include "nlk.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "nlk.selectorLabels" -}}
{{- if .Values.nlk.selectorLabels -}}
{{ toYaml .Values.nlk.selectorLabels }}
{{- else -}}
app.kubernetes.io/name: {{ include "nlk.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
{{- end -}}

{{/*
Expand the name of the configmap.
*/}}
{{- define "nlk.configName" -}}
{{- if .Values.nlk.customConfigMap -}}
{{ .Values.nlk.customConfigMap }}
{{- else -}}
{{- default (include "nlk.fullname" .) .Values.nlk.config.name -}}
{{- end -}}
{{- end -}}

{{/*
Expand service account name.
*/}}
{{- define "nlk.serviceAccountName" -}}
{{- default (include "nlk.fullname" .) .Values.nlk.serviceAccount.name -}}
{{- end -}}

{{- define "nlk.tag" -}}
{{- default .Chart.AppVersion .Values.nlk.image.tag -}}
{{- end -}}

{{/*
Expand image name.
*/}}
{{- define "nlk.image" -}}
{{- if .Values.nlk.image.digest -}}
{{- printf "%s/%s@%s" .Values.nlk.image.registry .Values.nlk.image.repository .Values.nlk.image.digest -}}
{{- else -}}
{{- printf "%s/%s:%s" .Values.nlk.image.registry .Values.nlk.image.repository (include "nlk.tag" .) -}}
{{- end -}}
{{- end -}}

{{- define "nlk.prometheus.serviceName" -}}
{{- printf "%s-%s" (include "nlk.fullname" .) "prometheus-service" -}}
{{- end -}}
18 changes: 18 additions & 0 deletions charts/nlk/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- if .Values.rbac.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ .Release.Namespace }}-{{ include "nlk.fullname" . }}
rules:
- apiGroups:
- ""
resources:
- configmaps
- nodes
- secrets
- services
verbs:
- get
- list
- watch
{{- end }}
14 changes: 14 additions & 0 deletions charts/nlk/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .Values.rbac.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ .Release.Namespace }}-{{ include "nlk.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ include "nlk.fullname" . }}
namespace: nlk
roleRef:
kind: ClusterRole
name: {{ .Release.Namespace }}-{{ include "nlk.fullname" . }}
apiGroup: rbac.authorization.k8s.io
{{- end }}
14 changes: 14 additions & 0 deletions charts/nlk/templates/nlk-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: nlk-config
namespace: nlk
data:
{{- if .Values.nlk.config.entries.hosts }}
nginx-hosts: "{{ .Values.nlk.config.entries.hosts }}"
{{- end }}
tls-mode: "{{ index .Values.nlk.defaultTLS "tls-mode" }}"
ca-certificate: "{{ index .Values.nlk.defaultTLS "ca-certificate" }}"
client-certificate: "{{ index .Values.nlk.defaultTLS "client-certificate" }}"
log-level: "{{ .Values.nlk.logLevel }}"

44 changes: 44 additions & 0 deletions charts/nlk/templates/nlk-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "nlk.fullname" . }}
namespace: nlk
labels:
app: nlk
spec:
replicas: {{ .Values.nlk.replicaCount }}
selector:
matchLabels:
app: nlk
template:
metadata:
labels:
app: nlk
spec:
containers:
- name: {{ .Chart.Name }}
image: {{ include "nlk.image" .}}
imagePullPolicy: {{ .Values.nlk.image.pullPolicy }}
ports:
{{- range $key, $value := .Values.nlk.containerPort }}
- name: {{ $key }}
containerPort: {{ $value }}
protocol: TCP
{{- end }}
{{- if .Values.nlk.liveStatus.enable }}
livenessProbe:
httpGet:
path: /livez
port: {{ .Values.nlk.liveStatus.port }}
initialDelaySeconds: {{ .Values.nlk.liveStatus.initialDelaySeconds }}
periodSeconds: {{ .Values.nlk.readyStatus.periodSeconds }}
{{- end }}
{{- if .Values.nlk.readyStatus.enable }}
readinessProbe:
httpGet:
path: /readyz
port: {{ .Values.nlk.readyStatus.port }}
initialDelaySeconds: {{ .Values.nlk.readyStatus.initialDelaySeconds }}
periodSeconds: {{ .Values.nlk.readyStatus.periodSeconds }}
{{- end }}
serviceAccountName: {{ include "nlk.fullname" . }}
8 changes: 8 additions & 0 deletions charts/nlk/templates/nlk-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "nlk.fullname" . }}
namespace: nlk
annotations:
kubernetes.io/service-account.name: {{ include "nlk.fullname" . }}
type: kubernetes.io/service-account-token
7 changes: 7 additions & 0 deletions charts/nlk/templates/nlk-serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{- if .Values.rbac.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "nlk.fullname" . }}
namespace: nlk
{{- end }}
Loading

0 comments on commit bd31460

Please sign in to comment.