Skip to content

Commit

Permalink
Merge pull request #76 from uselagoon/k8s_122
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon authored Jul 26, 2022
2 parents 48e9291 + b389858 commit 96821c2
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 37 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/build_and_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Image Build and Publish

on:
push:
branches:
- '**'
tags:
- 'v*.*.*'
pull_request:
branches:
- 'main'

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
# list of Docker images to use as base name for tags
images: |
uselagoon/remote-controller
ghcr.io/uselagoon/remote-controller
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
51 changes: 33 additions & 18 deletions .github/workflows/remote-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,20 @@ on:

jobs:
test-suite:
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
harbor: ["1.5.6", "1.6.4","1.7.5" ,"1.8.2","1.9.0"]
runs-on: ubuntu-latest
kindest_node_version: [v1.21.12, v1.22.9]
harbor: ["1.5.6", "1.9.0"]
lagoon_build_image: ["uselagoon/kubectl-build-deploy-dind:latest"]
experimental: [false]
# include:
# - kindest_node_version: v1.24.0
# harbor: "1.9.0"
# lagoon_build_image: "uselagoon/kubectl-build-deploy-dind:latest"
# experimental: true
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -26,36 +36,41 @@ jobs:
uses: actions/setup-go@v2
with:
go-version: '1.17'
- name: Install kustomize, kubebuilder, helm, docker-compose, kind
- name: Install kubebuilder
run: |
#kustomize
curl -sLo /tmp/kustomize_v3.5.4_linux_amd64.tar.gz https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv3.5.4/kustomize_v3.5.4_linux_amd64.tar.gz
sudo tar -C /usr/local/bin -xzf /tmp/kustomize_v3.5.4_linux_amd64.tar.gz
#kubebuilder
curl -sL https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.3.2/kubebuilder_2.3.2_linux_amd64.tar.gz | tar -xz -C /tmp/
sudo mkdir -p /usr/local/kubebuilder/bin
sudo mv /tmp/kubebuilder_2.3.2_linux_amd64/bin/* /usr/local/kubebuilder/bin
chmod +x /usr/local/kubebuilder/bin/*
#helm
curl -sL https://get.helm.sh/helm-v3.6.3-linux-amd64.tar.gz | tar -xz -C /tmp/
sudo mv /tmp/linux-amd64/helm /usr/local/bin/helm
chmod +x /usr/local/bin/helm
#docker-compose
sudo curl -sLo /usr/local/bin/docker-compose "https://github.com/docker/compose/releases/download/1.29.0/docker-compose-$(uname -s)-$(uname -m)"
sudo chmod +x /usr/local/bin/docker-compose
#kind
curl -sLo /tmp/kind https://github.com/kubernetes-sigs/kind/releases/download/v0.11.1/kind-linux-amd64
chmod +x /tmp/kind
sudo mv /tmp/kind /usr/local/bin/
echo "/usr/local/kubebuilder/bin" >> $GITHUB_PATH
- name: Check go, kustomize, kubebuilder, helm, kind versions
run: |
go version
kustomize version
helm version
kubebuilder version
kind version
- name: Create kind cluster
uses: helm/kind-action@v1.2.0
uses: helm/kind-action@v1.3.0
with:
version: v0.14.0
node_image: kindest/node:${{ matrix.kindest_node_version }}
config: test-resources/kind-config.yaml
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build
uses: docker/build-push-action@v2
with:
context: .
load: true
tags: uselagoon/remote-controller:test-tag
- name: Run Tests
run: |
export PATH=$PATH:/usr/local/kubebuilder/bin
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
export OVERRIDE_BUILD_DEPLOY_DIND_IMAGE="${{matrix.lagoon_build_image}}"
export HARBOR_VERSION=${{matrix.harbor}}
# export GO111MODULE=on
make controller-test
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ CRD_OPTIONS ?= "crd:trivialVersions=false"

CONTROLLER_NAMESPACE ?= lagoon-builddeploy

OVERRIDE_BUILD_DEPLOY_DIND_IMAGE ?= uselagoon/kubectl-build-deploy-dind:latest

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
Expand Down Expand Up @@ -38,10 +40,15 @@ outputcrds: manifests
uninstall: manifests
kustomize build config/crd | kubectl delete -f -

# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
preview: manifests
cd config/manager && kustomize edit set image controller=${IMG}
OVERRIDE_BUILD_DEPLOY_DIND_IMAGE=${OVERRIDE_BUILD_DEPLOY_DIND_IMAGE} kustomize build config/default

# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy: manifests
cd config/manager && kustomize edit set image controller=${IMG}
kustomize build config/default | kubectl apply -f -
OVERRIDE_BUILD_DEPLOY_DIND_IMAGE=${OVERRIDE_BUILD_DEPLOY_DIND_IMAGE} kustomize build config/default | kubectl apply -f -

# Generate manifests e.g. CRD, RBAC etc.
manifests: controller-gen
Expand Down
1 change: 1 addition & 0 deletions config/default/config.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
OVERRIDE_BUILD_DEPLOY_DIND_IMAGE
7 changes: 6 additions & 1 deletion config/default/envs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@ spec:
- name: CONTROLLER_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
fieldPath: metadata.namespace
- name: OVERRIDE_BUILD_DEPLOY_DIND_IMAGE
valueFrom:
configMapKeyRef:
name: overrides
key: OVERRIDE_BUILD_DEPLOY_DIND_IMAGE
4 changes: 4 additions & 0 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ bases:
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
#- ../prometheus

configMapGenerator:
- name: overrides
env: config.properties

patchesStrategicMerge:
- envs.yaml
# Protect the /metrics endpoint by putting it behind auth.
Expand Down
4 changes: 2 additions & 2 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: uselagoon/remote-controller
newTag: test-tag
newName: controller
newTag: latest
26 changes: 14 additions & 12 deletions controller-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ tear_down () {
kubectl get ingress --all-namespaces
echo "==> Get pods"
kubectl get pods --all-namespaces
echo "==> Get remote logs (docker-host)"
kubectl describe pods --namespace=lagoon --selector=app.kubernetes.io/name=lagoon-remote
kubectl logs --tail=80 --namespace=lagoon --prefix --timestamps --all-containers --selector=app.kubernetes.io/name=lagoon-remote
echo "==> Remove cluster"
kind delete cluster --name ${KIND_NAME}
echo "==> Remove services"
Expand All @@ -49,8 +52,6 @@ start_docker_compose_services () {
echo "==> Bring up local provider"
docker-compose up -d
CHECK_COUNTER=1
# echo "==> Ensure mariadb database provider is running"
# mariadb_start_check
}

mariadb_start_check () {
Expand Down Expand Up @@ -79,9 +80,7 @@ install_path_provisioner () {
}

build_deploy_controller () {
echo "==> Build and deploy controller"
make test
make docker-build IMG=${CONTROLLER_IMAGE}
echo "==> Install CRDs and deploy controller"
make install

kind load docker-image ${CONTROLLER_IMAGE} --name ${KIND_NAME}
Expand Down Expand Up @@ -145,13 +144,20 @@ check_lagoon_build () {
start_docker_compose_services
install_path_provisioner

echo "==> Install helm-git plugin"
helm plugin install https://github.com/aslafy-z/helm-git

echo "==> Install lagoon-remote docker-host"
helm repo add lagoon-remote https://uselagoon.github.io/lagoon-charts/
## configure the docker-host to talk to our insecure registry
kubectl create namespace lagoon
helm upgrade --install -n lagoon lagoon-remote lagoon-remote/lagoon-remote \
--set dockerHost.registry=http://harbor.172.17.0.1.nip.io:32080 \
--set dioscuri.enabled=false
--set dockerHost.storage.size=10Gi \
--set dockerHost.extraEnvs[0].name=DOCKER_TLS_VERIFY \
--set dockerHost.extraEnvs[0].value=1 \
--set dioscuri.enabled=false \
--set dbaas-operator.enabled=false
CHECK_COUNTER=1
echo "===> Ensure docker-host is running"
until $(kubectl -n lagoon get pods $(kubectl -n lagoon get pods | grep "lagoon-remote-docker-host" | awk '{print $1}') --no-headers | grep -q "Running")
Expand All @@ -162,9 +168,6 @@ if [ $CHECK_COUNTER -lt $CHECK_TIMEOUT ]; then
sleep 5
else
echo "Timeout of $CHECK_TIMEOUT for controller startup reached"
# kubectl -n lagoon get pods
# kubectl -n lagoon logs -f $(kubectl -n lagoon get pods | grep "lagoon-remote-docker-host" | awk '{print $1}')
# kubectl -n lagoon get pods $(kubectl -n lagoon get pods | grep "lagoon-remote-docker-host" | awk '{print $1}') -o yaml
check_controller_log
tear_down
echo "================ END ================"
Expand All @@ -177,11 +180,11 @@ echo "===> Docker-host is running"
echo "===> Install Ingress-Nginx"
kubectl create namespace ingress-nginx
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm upgrade --install -n ingress-nginx ingress-nginx ingress-nginx/ingress-nginx -f test-resources/ingress-nginx-values.yaml --version 3.31.0
helm upgrade --install -n ingress-nginx ingress-nginx ingress-nginx/ingress-nginx -f test-resources/ingress-nginx-values.yaml --version 4.0.16
NUM_PODS=$(kubectl -n ingress-nginx get pods | grep -ow "Running"| wc -l | tr -d " ")
if [ $NUM_PODS -ne 1 ]; then
echo "Install ingress-nginx"
helm upgrade --install -n ingress-nginx ingress-nginx ingress-nginx/ingress-nginx -f test-resources/ingress-nginx-values.yaml --version 3.31.0
helm upgrade --install -n ingress-nginx ingress-nginx ingress-nginx/ingress-nginx -f test-resources/ingress-nginx-values.yaml --version 4.0.16
kubectl get pods --all-namespaces
echo "Wait for ingress-nginx to become ready"
sleep 120
Expand Down Expand Up @@ -230,7 +233,6 @@ echo '
\"spec\": {
\"build\": {
\"ci\": \"true\",
\"image\": \"uselagoon\/kubectl-build-deploy-dind:latest\",
\"type\": \"branch\"
},
\"gitReference\": \"origin\/main\",
Expand Down
1 change: 0 additions & 1 deletion test-resources/example-project1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ metadata:
spec:
build:
ci: 'true' #to make sure that readwritemany is changed to readwriteonce
image: uselagoon/kubectl-build-deploy-dind:latest
type: branch
gitReference: origin/main
project:
Expand Down
1 change: 0 additions & 1 deletion test-resources/example-project2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ metadata:
spec:
build:
ci: 'true' #to make sure that readwritemany is changed to readwriteonce
image: uselagoon/kubectl-build-deploy-dind:latest
type: branch
gitReference: origin/main
project:
Expand Down
5 changes: 4 additions & 1 deletion test-resources/ingress-nginx-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ controller:
type: NodePort
nodePorts:
http: 32080
https: 32443
https: 32443
watchIngressWithoutClass: true
ingressClassResource:
default: true

0 comments on commit 96821c2

Please sign in to comment.