-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Split workflows and create initial CI setup with traefik (#39)
Required for #38
- Loading branch information
Showing
6 changed files
with
251 additions
and
168 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,83 @@ | ||
name: Checks deployment of kubenurse | ||
|
||
inputs: | ||
namespace: | ||
description: Namespace where the kubenurse is deployed | ||
required: true | ||
type: string | ||
svc-domain: | ||
description: Ingress domain on which the kubenurse is running | ||
required: true | ||
type: string | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- shell: bash | ||
run: | | ||
echo "Check number of kubenurses" | ||
test $(kubectl -n ${{ inputs.namespace }} get pods -l app=kubenurse \ | ||
| wc -l) -eq 4 # Test for 3 Pods + header | ||
- shell: bash | ||
run: | | ||
echo "Check for unexpected log lines" | ||
test $(kubectl -n ${{ inputs.namespace }} logs -l app=kubenurse \ | ||
| grep -v "I'm ready to help you" \ | ||
| wc -l) -eq 0 \ | ||
- shell: bash | ||
run: | | ||
echo "Check if the kubenurse had any restarts" | ||
kubectl -n ${{ inputs.namespace }} get pods -l app=kubenurse \ | ||
-o jsonpath='{range .items[*]}{.status.containerStatuses[0].restartCount}{"\n"}{end}' \ | ||
| (! grep -v 0) # Validate for 0 restarts | ||
- shell: bash | ||
run: | | ||
echo "Check that metrics contain kubenurse specific data" | ||
curl -k -s --resolve \ | ||
${{ inputs.svc-domain }}:443:127.0.0.1 \ | ||
https://${{ inputs.svc-domain }}:443/metrics \ | ||
| grep "kubenurse_request_" > /dev/null | ||
- shell: bash | ||
run: | | ||
echo "Check that metrics contain neighbours" | ||
curl -k -s --resolve \ | ||
${{ inputs.svc-domain }}:443:127.0.0.1 \ | ||
https://${{ inputs.svc-domain }}:443/metrics \ | ||
| grep "kubenurse_request_" | grep 'type="path_' > /dev/null | ||
- shell: bash | ||
run: | | ||
echo "Check that metrics contain no errors" | ||
curl -k -s --resolve \ | ||
${{ inputs.svc-domain }}:443:127.0.0.1 \ | ||
https://${{ inputs.svc-domain }}:443/metrics \ | ||
| (! grep "kubenurse_errors_total") | ||
- shell: bash | ||
run: | | ||
echo "Check the neighbourhood state" | ||
curl -k -s --resolve \ | ||
${{ inputs.svc-domain }}:443:127.0.0.1 \ | ||
https://${{ inputs.svc-domain }}:443/alive \ | ||
| grep '"neighbourhood_state": "ok"' > /dev/null | ||
- shell: bash | ||
run: | | ||
echo "Check that discovery is ok and status page includes neighbours" | ||
curl -k -s --resolve \ | ||
${{ inputs.svc-domain }}:443:127.0.0.1 \ | ||
https://${{ inputs.svc-domain }}:443/alive \ | ||
| grep '"neighbourhood": \[' > /dev/null # If no others are discovered, this is null | ||
- shell: bash | ||
run: | | ||
echo "Show kubenurse status" | ||
curl -k -s --resolve \ | ||
${{ inputs.svc-domain }}:443:127.0.0.1 \ | ||
https://${{ inputs.svc-domain }}:443/alive | ||
if: ${{ always() }} | ||
- shell: bash | ||
run: | | ||
echo "Describe resources on failure" | ||
kubectl -n ${{ inputs.namespace }} get pods -o wide | ||
kubectl -n ${{ inputs.namespace }} logs -l app=kubenurse | ||
kubectl -n ${{ inputs.namespace }} describe pods -l app=kubenurse | ||
kubectl -n ${{ inputs.namespace }} describe daemonsets -l app=kubenurse | ||
kubectl -n ${{ inputs.namespace }} get events | ||
if: ${{ failure() }} |
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,64 @@ | ||
--- | ||
name: deploy with helm and ingress-nginx | ||
on: | ||
push: | ||
pull_request: | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17 | ||
- name: GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
version: latest | ||
args: release --snapshot --rm-dist --skip-publish | ||
- name: Setup kind | ||
uses: engineerd/setup-kind@v0.5.0 | ||
with: | ||
config: "ci/kind-config.yaml" | ||
version: "v0.11.1" | ||
image: kindest/node:v1.23.1 | ||
- name: Show cluster info and switch to kube-system | ||
run: | | ||
kubectl cluster-info | ||
kubectl get nodes | ||
echo "current-context:" $(kubectl config current-context) | ||
kubectl config set-context --current --namespace kube-system | ||
- name: Deploy ingress-nginx | ||
timeout-minutes: 2 | ||
run: | | ||
kubectl apply -f \ | ||
https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/kind/deploy.yaml | ||
kubectl wait --namespace ingress-nginx \ | ||
--for=condition=ready pod --selector=app.kubernetes.io/component=controller --timeout=90s | ||
- name: Import image into kind | ||
run: | | ||
docker images | ||
docker tag postfinance/kubenurse:latest \ | ||
postfinance/kubenurse:latest-ci | ||
kind load docker-image postfinance/kubenurse:latest-ci | ||
- name: Deploy example setup | ||
run: | | ||
helm upgrade kubenurse \ | ||
--install helm/kubenurse/ \ | ||
-f helm/kubenurse/values.yaml \ | ||
--set ingress.url=ingress-nginx-controller.ingress-nginx.svc.cluster.local,daemonset.image.tag=latest-ci \ | ||
--wait | ||
- name: Wait for pods | ||
timeout-minutes: 2 | ||
run: | | ||
sleep 15 # wait for the scheduler to create pods | ||
kubectl -n kube-system wait pods -l app=kubenurse --for=condition=Ready | ||
kubectl -n kube-system get pods -l app=kubenurse | ||
sleep 60 # Wait to generate some checks etc. | ||
- name: Check deployment | ||
uses: ./.github/actions/check-deployment | ||
with: | ||
namespace: kube-system | ||
svc-domain: ingress-nginx-controller.ingress-nginx.svc.cluster.local |
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,68 @@ | ||
--- | ||
# TODO: This job is still in development and is therefor only run on ci-traefik | ||
name: deploy with helm and traefik | ||
on: | ||
push: | ||
branches: | ||
- ci-traefik | ||
pull_request: | ||
branches: | ||
- ci-traefik | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17 | ||
- name: GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
version: latest | ||
args: release --snapshot --rm-dist --skip-publish | ||
- name: Setup kind | ||
uses: engineerd/setup-kind@v0.5.0 | ||
with: | ||
config: "ci/kind-config.yaml" | ||
version: "v0.11.1" | ||
image: kindest/node:v1.23.1 | ||
- name: Show cluster info and switch to kube-system | ||
run: | | ||
kubectl cluster-info | ||
kubectl get nodes | ||
echo "current-context:" $(kubectl config current-context) | ||
kubectl config set-context --current --namespace kube-system | ||
- name: Deploy traefik | ||
timeout-minutes: 2 | ||
run: | | ||
helm repo add traefik https://helm.traefik.io/traefik | ||
helm repo update | ||
helm install --namespace=kube-system -f ./ci/traefik-config.yaml traefik traefik/traefik | ||
- name: Import image into kind | ||
run: | | ||
docker images | ||
docker tag postfinance/kubenurse:latest \ | ||
postfinance/kubenurse:latest-ci | ||
kind load docker-image postfinance/kubenurse:latest-ci | ||
- name: Deploy example setup | ||
run: | | ||
helm upgrade kubenurse \ | ||
--install helm/kubenurse/ \ | ||
-f helm/kubenurse/values.yaml \ | ||
--set ingress.url=ingress-nginx-controller.ingress-nginx.svc.cluster.local,daemonset.image.tag=latest-ci \ | ||
--wait | ||
- name: Wait for pods | ||
timeout-minutes: 2 | ||
run: | | ||
sleep 15 # wait for the scheduler to create pods | ||
kubectl -n kube-system wait pods -l app=kubenurse --for=condition=Ready | ||
kubectl -n kube-system get pods -l app=kubenurse | ||
sleep 60 # Wait to generate some checks etc. | ||
- name: Check deployment | ||
uses: ./.github/actions/check-deployment | ||
with: | ||
namespace: kube-system | ||
svc-domain: ingress-nginx-controller.ingress-nginx.svc.cluster.local |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.