Skip to content

Commit

Permalink
Feat: Add spec tests for new installation method and fix minor bugs
Browse files Browse the repository at this point in the history
Refs: #2168
- New setup spec tests were introduced to verify that the installation
  method from #2161 works as intended.
- Three distinct issues were discovered and resolved:
  * Helm directories with variable depth levels could not be discovered
  after initialization (resolved through File.basename).
  * Configs that weren't named cnf-testsuite.yml could not
  be discovered after initialization (resolved by changing the name
  internally when copying the file).
  * Existence of manifest folder was not checked (resolved by adding an
  if check).
- Additionally a common point of failure was added with a failure
  message that was previously not present.
- The issue #2176 was also discovered during attempted deployment of
  sample-cnfs/sample-elk-stack which was also added in this commit and
  is to be used in future spec test.

Signed-off-by: svteb <[email protected]>
  • Loading branch information
svteb committed Nov 13, 2024
1 parent 2bcd444 commit df63e7a
Show file tree
Hide file tree
Showing 128 changed files with 11,560 additions and 22 deletions.
4 changes: 4 additions & 0 deletions sample-cnfs/sample-bad-config/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
config_version: v2
deployments:
vorp: "glup 👽"
12 changes: 12 additions & 0 deletions sample-cnfs/sample-conflicting-deployments/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
config_version: v2
deployments:
helm_charts:
- name: nginx
helm_repo_name: bitnami
helm_repo_url: https://charts.bitnami.com/bitnami
helm_chart_name: nginx
helm_values: --set replicaCount=1
manifests:
- name: nginx
manifest_directory: manifests
40 changes: 40 additions & 0 deletions sample-cnfs/sample-conflicting-deployments/manifests/pod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
app: nginx
spec:
containers:
- image: bitnami/nginx:1.20
name: nginx
command:
- /opt/bitnami/scripts/nginx/entrypoint.sh
- /opt/bitnami/scripts/nginx/run.sh
livenessProbe:
tcpSocket:
port: 8080
readinessProbe:
tcpSocket:
port: 8080
resources: {}
ports:
- containerPort: 8080
- containerPort: 8443
dnsPolicy: Default

---
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
selector:
app: nginx
ports:
- name: http
protocol: TCP
port: 8080
targetPort: 8080
externalIPs:
- 2.2.2.2
20 changes: 20 additions & 0 deletions sample-cnfs/sample-elk-stack/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
config_version: "v2"

deployments:
helm_charts:
- name: elasticsearch
helm_repo_name: elastic
helm_repo_url: https://helm.elastic.co
helm_chart_name: elasticsearch
helm_values: "--set replicas=1"
- name: logstash
helm_repo_name: elastic
helm_repo_url: https://helm.elastic.co
helm_chart_name: logstash
helm_values: "--set replicaCount=1"
- name: kibana
helm_repo_name: elastic
helm_repo_url: https://helm.elastic.co
helm_chart_name: kibana
helm_values: "--set replicaCount=1"
12 changes: 12 additions & 0 deletions sample-cnfs/sample-nginx-redis/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
config_version: v2
deployments:
helm_charts:
- name: nginx
helm_repo_name: bitnami
helm_repo_url: https://charts.bitnami.com/bitnami
helm_chart_name: nginx
helm_values: --set replicaCount=1
manifests:
- name: redis
manifest_directory: redis-manifests
21 changes: 21 additions & 0 deletions sample-cnfs/sample-nginx-redis/redis-manifests/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis
labels:
app: redis
spec:
replicas: 1
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: redis:6.2
ports:
- containerPort: 6379
11 changes: 11 additions & 0 deletions sample-cnfs/sample-nginx-redis/redis-manifests/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: redis
spec:
type: ClusterIP
selector:
app: redis
ports:
- port: 6379
targetPort: 6379
13 changes: 13 additions & 0 deletions sample-cnfs/sample-partial-deployment-failure/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
config_version: v2
deployments:
helm_charts:
- name: nginx
helm_repo_name: bitnami
helm_repo_url: https://charts.bitnami.com/bitnami
helm_chart_name: nginx
helm_values: --set replicaCount=1
- name: coredns
helm_chart_name: coredns
helm_repo_name: badrepo
helm_repo_url: https://bad-helm-repo.googleapis.com
10 changes: 10 additions & 0 deletions sample-cnfs/sample_multiple_deployments/cnf-testsuite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
config_version: v2
deployments:
helm_dirs:
- name: coredns
helm_directory: coredns
- name: memcached
helm_directory: memcached
- name: nginx
helm_directory: nginx
22 changes: 22 additions & 0 deletions sample-cnfs/sample_multiple_deployments/coredns/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
OWNERS
24 changes: 24 additions & 0 deletions sample-cnfs/sample_multiple_deployments/coredns/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
annotations:
artifacthub.io/changes: |
- kind: fix
description: Add default values to chart to fix cluster role name templating issue
apiVersion: v2
appVersion: 1.11.3
description: CoreDNS is a DNS server that chains plugins and provides Kubernetes DNS
Services
home: https://coredns.io
icon: https://coredns.io/images/CoreDNS_Colour_Horizontal.png
keywords:
- coredns
- dns
- kubedns
maintainers:
- name: mrueg
- name: haad
- name: hagaibarel
- name: shubham-cmyk
name: coredns
sources:
- https://github.com/coredns/coredns
type: application
version: 1.36.1
255 changes: 255 additions & 0 deletions sample-cnfs/sample_multiple_deployments/coredns/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{- if .Values.isClusterService }}
CoreDNS is now running in the cluster as a cluster-service.
{{- else }}
CoreDNS is now running in the cluster.
It can be accessed using the below endpoint
{{- if contains "NodePort" .Values.serviceType }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "coredns.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo "$NODE_IP:$NODE_PORT"
{{- else if contains "LoadBalancer" .Values.serviceType }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status by running 'kubectl get svc -w {{ template "coredns.fullname" . }}'

export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "coredns.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo $SERVICE_IP
{{- else if contains "ClusterIP" .Values.serviceType }}
"{{ template "coredns.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local"
from within the cluster
{{- end }}
{{- end }}

It can be tested with the following:

1. Launch a Pod with DNS tools:

kubectl run -it --rm --restart=Never --image=infoblox/dnstools:latest dnstools

2. Query the DNS server:

/ # host kubernetes
Loading

0 comments on commit df63e7a

Please sign in to comment.