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

rename test for k8s-labs #68

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ jobs:
uses: ./.github/workflows/package-test.yaml
with:
package-name: dvga
test-arrrspace:
test-k8s-labs:
uses: ./.github/workflows/package-test.yaml
with:
package-name: arrrspace
package-name: k8s-labs
test-amoksecurity:
uses: ./.github/workflows/package-test.yaml
with:
Expand Down
88 changes: 44 additions & 44 deletions modules/targets/k8s-labs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

- name: Get the k8s-labs repo
git:
repo: https://github.com/ProfessionallyEvil/k8s-lab.git
repo: https://github.com/ProfessionallyEvil/k8s-labs.git
dest: /opt/targets/k8s-labs

- name: Download minikube bin
Expand Down Expand Up @@ -50,14 +50,52 @@
dest: /etc/hosts
line: '127.0.0.1 api.k8s-labs.wtf'

remove:
- name: Remove repo
rm:
path: /opt/targets/k8s-labs
- name: Delete cluster
command:
cmd: minikube delete
- name: Remove images
command:
unsafe: True
shell: True
cmd: docker rmi $(docker images --format '{{.Repository}}:{{.Tag}}' | grep 'k8slabs')
- name: Cleanup .kube dir
rm:
path: /root/.kube
- name: Cleanup .minikube dir
rm:
path: /root/.minikube
- name: Remove minikube
rm:
path: /usr/bin/minikube
- name: Remove kubectl
rm:
path: /usr/bin/kubectl
- name: Remove nginx conf
rm:
path: /etc/nginx/conf.d/k8s-labs.conf
- name: Remove api.k8s-labs nginx conf
rm:
path: /etc/nginx/conf.d/api.k8s-labs.conf

start:
- service:
name: docker
state: running
- command:
cmd: minikube start --force

# hacks to make this work more dynamically without supporting state in katana manifests
- name: Write cluster IP to file
command:
unsafe: True
shell: True
cwd: /opt/targets/k8s-labs
cmd: "minikube ip > /opt/targets/k8s-labs/cluster_ip.txt"
cmd: "/usr/bin/minikube ip > /opt/targets/k8s-labs/cluster_ip.txt"

- name: Set up web app nginx reverse-proxy config
copy:
dest: /etc/nginx/conf.d/k8s-labs.conf
Expand All @@ -70,7 +108,7 @@
}
}
mode: 0644

- name: Set up api nginx reverse-proxy config
copy:
dest: /etc/nginx/conf.d/api.k8s-labs.conf
Expand All @@ -83,7 +121,7 @@
}
}
mode: 0644

- name: Set cluster IP in nginx configs
command:
shell: True
Expand All @@ -93,45 +131,7 @@
- service:
name: nginx
state: restarted

remove:
- name: Remove repo
rm:
path: /opt/targets/k8s-labs
- name: Delete cluster
command:
cmd: minikube delete
- name: Remove images
command:
unsafe: True
shell: True
cmd: docker rmi $(docker images --format '{{.Repository}}:{{.Tag}}' | grep 'k8slabs')
- name: Cleanup .kube dir
rm:
path: /root/.kube
- name: Cleanup .minikube dir
rm:
path: /root/.minikube
- name: Remove minikube
rm:
path: /usr/bin/minikube
- name: Remove kubectl
rm:
path: /usr/bin/kubectl
- name: Remove nginx conf
rm:
path: /etc/nginx/conf.d/k8s-labs.conf
- name: Remove api.k8s-labs nginx conf
rm:
path: /etc/nginx/conf.d/api.k8s-labs.conf

start:
- service:
name: docker
state: running
- command:
cmd: minikube start --force


stop:
- service:
name: docker
Expand Down
14 changes: 0 additions & 14 deletions test/test-arrrspace.sh

This file was deleted.

16 changes: 16 additions & 0 deletions test/test-k8s-labs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -e

katana install k8s-labs
sleep 2
katana start k8s-labs

curl --fail -o /dev/null --retry 5 --retry-all-errors http://k8s-labs.wtf:80/
curl --fail -o /dev/null --retry 5 --retry-all-errors http://api.k8s-labs.wtf:80/

katana stop k8s-labs
sleep 2
katana remove k8s-labs

echo -e "\nPASSED\n"
Loading