Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: (CCIE-3085) validate the output of helm template using kubectl #63

Merged
merged 37 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
17161ed
test trigger
dtsai-czi Apr 25, 2024
9e05e02
minimal value change
dtsai-czi Apr 25, 2024
e988f0b
revert value change
dtsai-czi Apr 25, 2024
9b07831
specify root as ct chart directory
dtsai-czi Apr 25, 2024
c376902
add gha jobs with test fixtures for validating template outputs
dtsai-czi Jul 22, 2024
366b9b1
Merge branch 'main' of github.com:chanzuckerberg/argo-helm-charts int…
dtsai-czi Jul 22, 2024
1add332
Merge branch 'main' into template-out-validation
alexlokshin-czi Aug 29, 2024
a622ba6
update dependency
dtsai-czi Aug 30, 2024
86687fd
Merge branch 'template-out-validation' of github.com:chanzuckerberg/a…
dtsai-czi Aug 30, 2024
6618e13
build dep
dtsai-czi Aug 30, 2024
4100d4b
update and build
dtsai-czi Aug 30, 2024
56a8e71
disable oidc proxy in default test fixture
dtsai-czi Aug 30, 2024
b294fd9
debug
dtsai-czi Aug 30, 2024
dfc3091
debug
dtsai-czi Aug 30, 2024
7b608b8
remove build
dtsai-czi Aug 30, 2024
1ef5ff3
remove update
dtsai-czi Aug 30, 2024
e992eb1
build
dtsai-czi Aug 30, 2024
aea2b3a
update
dtsai-czi Aug 30, 2024
ee2daa8
add repo
dtsai-czi Aug 30, 2024
7c6cc4d
debug
dtsai-czi Aug 30, 2024
5e9c172
add kind cluster
dtsai-czi Aug 30, 2024
b51ef8a
force cluster
dtsai-czi Aug 30, 2024
7ac41a6
echo template
dtsai-czi Aug 30, 2024
01b24a3
debug
dtsai-czi Aug 30, 2024
f950633
debug
dtsai-czi Aug 30, 2024
7739180
get error
dtsai-czi Aug 30, 2024
857fcff
suppress exit code
dtsai-czi Aug 30, 2024
eca7a8c
suppress exit code of invalid values
dtsai-czi Aug 30, 2024
db88bb7
update setup-kubectl
dtsai-czi Aug 30, 2024
fc7b2f9
remove redirect
dtsai-czi Aug 30, 2024
517e4de
disable validate
dtsai-czi Aug 30, 2024
c002f08
verbose
dtsai-czi Aug 30, 2024
80f6038
max verbosity
dtsai-czi Aug 30, 2024
f4f6170
debug get nodes
dtsai-czi Aug 30, 2024
e7558ec
get contexts
dtsai-czi Aug 30, 2024
2587b3b
try kind cluster
dtsai-czi Aug 30, 2024
c2605da
cleanup
dtsai-czi Aug 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion .github/workflows/chart-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Lint and Test Charts
on: pull_request

jobs:

lint-test:
runs-on: ubuntu-latest
steps:
Expand All @@ -16,6 +17,27 @@ jobs:
with:
version: v3.14.0

- name: Set up kubectl
uses: azure/setup-kubectl@v3

- name: Validate chart template with default values
run: |
output=$(helm template ./stack --values ./test-fixtures/values.yaml | kubectl apply -f - --dry-run=client 2>&1)
if [[ $output -ne "error: no objects passed to apply" ]]; then
exit 1
fi

- name: Validate chart template with invalid values
run: |
output=$(helm template ./stack --values ./test-fixtures/values1.yaml | kubectl apply -f - --dry-run=client 2>&1)
if [[ $output -ne "Error: failed to parse ./test-fixtures/values1.yaml: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type map[string]interface {}" ]]; then
exit 1
fi

- name: Validate chart template with valid values
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cannot run without a cluster running, so I moved kind cluster creation to an earlier step and made it unconditional

run: |
helm template ./stack --values ./test-fixtures/values2.yaml | kubectl apply -f - --dry-run=client 2>&1

- uses: actions/setup-python@v4
with:
python-version: '3.12'
Expand All @@ -27,7 +49,7 @@ jobs:
- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
changed=$(ct list-changed --chart-dirs . --target-branch ${{ github.event.repository.default_branch }})
if [[ -n "$changed" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
Expand Down
182 changes: 182 additions & 0 deletions test-fixtures/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# Service defaults
global:
replicaCount: 1

# Settings for the primary container
image:
repository: nginx
pullPolicy: IfNotPresent
tag: "latest"

args: []
command: []

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

dnsPolicy: ClusterFirst
restartPolicy: Always

# Probes for the primary container
livenessProbe:
failureThreshold: 3
httpGet:
path: /
port: http
scheme: HTTP
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
initialDelaySeconds: 30
readinessProbe:
failureThreshold: 3
httpGet:
path: /
port: http
scheme: HTTP
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
initialDelaySeconds: 30
startupProbe:
enabled: false
failureThreshold: 3
successThreshold: 1
initialDelaySeconds: 0
timeoutSeconds: 1
periodSeconds: 10
exec:
command:
- ps
- '-ef'

resources:
limits:
cpu: '1'
memory: '1Gi'
requests:
cpu: '100m'
memory: '128Mi'

service:
type: ClusterIP
port: 80

initContainers: []
sidecars: []

appConfig:
envContextConfigMapName: "" # App environment level configuration configmap name
stackContextConfigMapName: "" # Stack level configuration configmap name
envSecretName: "" # App environment level configuration secret name
stackSecretName: "" # Stack level configuration secret name

# Global annotations to add to all resources
annotations: {}
# Annotations to add to pods
podAnnotations: {}
# Labels to add to pods
podLabels: {}

serviceAccount:
# Specifies whether a service account should be created
create: false
# Automatically mount a ServiceAccount's API credentials?
automount: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""

podSecurityContext: {}
# fsGroup: 2000

securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

ingress:
enabled: true
className: ""
host: chart-example.local
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- paths:
- path: /
pathType: ImplementationSpecific
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local

autoscaling:
enabled: true
minReplicas: 1
maxReplicas: 10
targetCPUUtilizationPercentage: 80
targetMemoryUtilizationPercentage: 80

# Additional volumes on the output Deployment definition.
volumes: []
# - name: foo
# secret:
# secretName: mysecret
# optional: false

# Additional volumeMounts on the output Deployment definition.
volumeMounts: []
# - name: foo
# mountPath: "/etc/foo"
# readOnly: true

nodeSelector:
kubernetes.io/arch: arm64

tolerations: []

affinity: {}

topologySpreadConstraints: []

# Service overrides
services: {}
# service1:
# args: ["arg1", "arg2"]
# command: ["command1", "command2"]
# autoscaling:
# enabled: true
# minReplicas: 2
# maxReplicas: 10
# maxUnavailable: 1
# replicaCount: 2
# sidecars:
# - name: sidecar1
# image: "sidecar1:latest"
# - name: sidecar2
# image: "sidecar2:latest"
# initContainers:
# - name: initContainer1
# image: "alpine:latest"
# command: ["echo", "Hello World"]
# service2:
# startupProbe:
# enabled: true
# autoscaling:
# enabled: true
# minReplicas: 2
# maxReplicas: 10
# maxUnavailable: 1
# replicaCount: 2
# sidecars:
# - name: sidecar3
# image: sidecar3:latest
# - name: sidecar4
# image: sidecar4:latest
1 change: 1 addition & 0 deletions test-fixtures/values1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$
Loading
Loading