-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
env0 User
committed
Jun 3, 2024
1 parent
ec08f68
commit 045735e
Showing
23 changed files
with
332 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Sanity tests for the agent helm chart | ||
|
||
It runs the `helm install --dry-run -f ./default.values.yaml,<values file>` command for each yaml file in `test-cases` directory. The `values` file is the `values.yaml` file in the `test-cases` directory. | ||
Dry run validates the rendered k8s manifests using schema from the actual k8s cluster, so you need cluster credentials available (works with local cluster too). | ||
It does not deploy the resources to the cluster. | ||
|
||
To add a new test create a new file in the `test-cases` directory and helm values as needed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"agentKey": "shag-test" | ||
"apiGatewayUrl": "https://shag-test.agent.env0.com/shag-test" | ||
"awsAccessKeyIdEncoded": "dGVzdF9hY2Nlc3Nfa2V5" | ||
"awsSecretAccessKeyEncoded": "dGVzdF9zZWNyZXRfa2V5" | ||
"env0ApiGwKeyEncoded": "dGVzdF9hcGlfZ3dfa2V5" | ||
"isSelfHosted": "true" | ||
"outputLogsLogGroupName": "prerequisites-dev-k8s-shag-logs" | ||
stage: dev | ||
dockerImage: ghcr.io/env0/deployment-agent:dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
version: 2 | ||
deploy: | ||
steps: | ||
setupVariables: | ||
after: | ||
- name: EKS update kubeconfig | ||
run: aws eks --region $AWS_DEFAULT_REGION update-kubeconfig --name $EKS_CLUSTER_NAME | ||
- name: Helm dry run | ||
run: ./helm_dry_run.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env bash | ||
|
||
GREEN='\033[1;32m' | ||
RED='\033[1;31m' | ||
NC='\033[0m' # No Color | ||
|
||
info() { | ||
echo "$1" | ||
} | ||
|
||
success() { | ||
echo -e "${GREEN}$1${NC}" | ||
} | ||
|
||
error() { | ||
echo -e "${RED}$1${NC}" | ||
} | ||
|
||
all_successful=true | ||
failed_tests=() | ||
|
||
for values_file in ./test-cases/*.yaml | ||
do | ||
# Check if the file is a regular file | ||
if [ -f "$values_file" ]; then | ||
info "------------------------------------------------------------------------------------------------------" | ||
info "Running dry-run for values file: $values_file" | ||
info "------------------------------------------------------------------------------------------------------" | ||
|
||
helm install agent ../ --dry-run -f "./default.values.yaml,$values_file" | ||
|
||
if [ $? -ne 0 ]; then | ||
error "Dry-run failed for values file: $values_file" | ||
all_successful=false | ||
failed_tests+=("$values_file") | ||
else | ||
success "Dry-run succeeded for values file: $values_file" | ||
fi | ||
|
||
fi | ||
done | ||
|
||
if ! $all_successful; then | ||
error "\n\n------------------------------------------------------------------------------------------------------" | ||
error "The following tests failed:" | ||
error "------------------------------------------------------------------------------------------------------" | ||
for failed_test in "${failed_tests[@]}" | ||
do | ||
error "$failed_test" | ||
done | ||
error "------------------------------------------------------------------------------------------------------" | ||
exit 1 | ||
else | ||
success "\n\n------------------------------------------------------------------------------------------------------" | ||
success "All tests passed successfully!" | ||
success "------------------------------------------------------------------------------------------------------" | ||
exit 0 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
resource "null_resource" "test" {} |
11 changes: 11 additions & 0 deletions
11
sanity-tests/test-cases/additional-env-vars-and-custom-secrests.values.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
podAdditionalEnvVars: | ||
SOME_API_URL: https://api.example.com | ||
TENANT_ID: "12345" | ||
|
||
customSecrets: | ||
- envVarName: SOME_API_KEY | ||
secretName: some-api-key | ||
key: api_key | ||
- envVarName: SOME_API_SECRET | ||
secretName: some-api-secret | ||
key: api_secret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
podAdditionalEnvVars: | ||
SOME_API_URL: https://api.example.com | ||
TENANT_ID: "12345" |
12 changes: 12 additions & 0 deletions
12
sanity-tests/test-cases/additional-labels-and-annotations.values.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
podAdditionalLabels: | ||
deployment-label1: value1 | ||
deployment-label2: value2 | ||
podAdditionalAnnotations: | ||
deployment-annotation1: value1 | ||
deployment-annotation2: value2 | ||
agentAdditionalLabels: | ||
agent-label1: value1 | ||
agent-label2: value2 | ||
agentAdditionalAnnotations: | ||
agent-annotation1: value1 | ||
agent-annotation2: value2 |
17 changes: 17 additions & 0 deletions
17
sanity-tests/test-cases/affinity-with-override.values.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
affinity: | ||
nodeAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: nodegroup | ||
operator: In | ||
values: | ||
- env0-system | ||
deploymentAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: nodegroup | ||
operator: In | ||
values: | ||
- env0-deployment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
affinity: | ||
nodeAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: nodegroup | ||
operator: In | ||
values: | ||
- env0-system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
customCertificates: | ||
- db-self-signed | ||
- org-root-cert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
customSecrets: | ||
- envVarName: SOME_API_KEY | ||
secretName: some-api-key | ||
key: api_key | ||
- envVarName: SOME_API_SECRET | ||
secretName: some-api-secret | ||
key: api_secret |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
strictSecurityContext: true | ||
runAsUser: '1000000000' | ||
runAsGroup: '1000000000' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
tolerations: | ||
- key: "key1" | ||
operator: "Equal" | ||
value: "value1" | ||
effect: "NoSchedule" | ||
- key: "key2" | ||
operator: "Exists" | ||
effect: "NoExecute" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
agentProxy: | ||
install: true | ||
enableVcsWebhooksProxy: true | ||
requests: | ||
cpu: 100m | ||
memory: 128Mi | ||
limits: | ||
cpu: 200m | ||
memory: 512Mi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{{- define "env0-agent.additional-env-vars-and-custom-secrets" -}} | ||
|
||
{{- $additional_env_vars := list -}} | ||
{{- $additional_secrets := list -}} | ||
|
||
{{- range $key, $value := .Values.podAdditionalEnvVars -}} | ||
{{- $additional_env_vars = append $additional_env_vars (printf "\"%s\"" $key) -}} | ||
{{- end -}} | ||
|
||
{{- range $index, $secret := .Values.customSecrets -}} | ||
{{- $additional_env_vars = append $additional_env_vars (printf "\"%s\"" $secret.envVarName) -}} | ||
{{- $additional_secrets = append $additional_secrets (printf "\"%s\"" $secret.envVarName) -}} | ||
{{- end -}} | ||
|
||
{{- if $additional_env_vars }} | ||
- name: ADDITIONAL_ENV_VARS | ||
value: '[{{ $additional_env_vars | join "," }}]' | ||
{{- end -}} | ||
|
||
{{- if $additional_secrets }} | ||
- name: ADDITIONAL_SECRETS_NAMES | ||
value: '{{ $additional_secrets | join "," }}' | ||
{{- end -}} | ||
|
||
{{- range $key, $value := .Values.podAdditionalEnvVars }} | ||
- name: {{ $key }} | ||
value: {{ $value | quote }} | ||
{{- end -}} | ||
|
||
{{- range $index, $secret := .Values.customSecrets }} | ||
- name: {{ $secret.envVarName }} | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ $secret.secretName }} | ||
key: {{ $secret.key }} | ||
{{- end -}} | ||
|
||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{{- define "env0-agent.affinity" }} | ||
{{- if . -}} | ||
affinity: {{ . | toYaml | trim | nindent 2 }} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{- define "env0-agent.tolerations" -}} | ||
{{- if . -}} | ||
tolerations: {{ . | toYaml | trim | nindent 2 }} | ||
{{- end -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{{- define "env0-agent.customCertificatesVolumes" -}} | ||
{{- if .Values.customCertificates -}} | ||
- name: etc-ssl-certs | ||
emptyDir: { } | ||
- name: custom-certificates | ||
projected: | ||
sources: | ||
{{- range .Values.customCertificates }} | ||
- secret: | ||
name: {{ . }} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{- define "env0-agent.customCertificatesVolumesMounts" -}} | ||
{{- if .Values.customCertificates -}} | ||
- name: etc-ssl-certs | ||
mountPath: /etc/ssl/certs | ||
- name: custom-certificates | ||
mountPath: /usr/local/share/ca-certificates | ||
readOnly: true | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{- define "env0-agent.customCertificatesNodeOptions" -}} | ||
{{- if .Values.customCertificates -}} | ||
- name: NODE_EXTRA_CA_CERTS | ||
value: /etc/ssl/certs/ca-certificates.crt | ||
{{- end -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.