Skip to content

Commit

Permalink
Kubernetes 1.22 support (#50)
Browse files Browse the repository at this point in the history
* Upgrade kube webhook certgen to support kubernetes 1.22.

* Other fixes to better support kubernetes 1.22.

* Run e2e tests for kubernetes 1.21 and 1.22.

* Fix helm install commands.

* Regenerate CRD with updated controller-gen. Remove deprecated `trivialVersions` CRD generation option.

Signed-off-by: Tomash Sidei <[email protected]>
  • Loading branch information
tomashibm authored Nov 8, 2021
1 parent d93daa4 commit 5d86ed1
Show file tree
Hide file tree
Showing 12 changed files with 576 additions and 55 deletions.
42 changes: 41 additions & 1 deletion .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,47 @@ jobs:
docker build -f Dockerfile.varnishd -t ibmcom/varnish:local .
docker build -f Dockerfile.controller -t ibmcom/varnish-controller:local .
docker build -f Dockerfile.exporter -t ibmcom/varnish-metrics-exporter:local .
- name: Create k8s Kind Cluster v1.22.0
uses: helm/[email protected]
with:
version: v0.11.1
cluster_name: e2e-tests
node_image: kindest/node:v1.22.0@sha256:b8bda84bb3a190e6e028b1760d277454a72267a5454b57db34437c34a588d047
- name: create namespace
run: kubectl create namespace varnish-operator
- name: load images
run: |
kind load --name e2e-tests docker-image ibmcom/varnish-operator:local
kind load --name e2e-tests docker-image ibmcom/varnish:local
kind load --name e2e-tests docker-image ibmcom/varnish-controller:local
kind load --name e2e-tests docker-image ibmcom/varnish-metrics-exporter:local
- name: install operator
id: helm
run: helm install varnish-operator --debug --namespace=varnish-operator varnish-operator --wait --set container.imagePullPolicy=Never --set container.image=ibmcom/varnish-operator:local
- name: run tests
run: go test -count=1 ./tests #-count=1 is to disable tests caching.
- name: delete cluster
run: kind delete cluster --name=e2e-tests
- name: Create k8s Kind Cluster v1.21.1
uses: helm/[email protected]
with:
version: v0.11.1
cluster_name: e2e-tests
node_image: kindest/node:v1.21.1@sha256:69860bda5563ac81e3c0057d654b5253219618a22ec3a346306239bba8cfa1a6
- name: create namespace
run: kubectl create namespace varnish-operator
- name: load images
run: |
kind load --name e2e-tests docker-image ibmcom/varnish-operator:local
kind load --name e2e-tests docker-image ibmcom/varnish:local
kind load --name e2e-tests docker-image ibmcom/varnish-controller:local
kind load --name e2e-tests docker-image ibmcom/varnish-metrics-exporter:local
- name: install operator
run: helm install varnish-operator --debug --namespace=varnish-operator varnish-operator --wait --set container.imagePullPolicy=Never --set container.image=ibmcom/varnish-operator:local
- name: run tests
run: go test -count=1 ./tests #-count=1 is to disable tests caching.
- name: delete cluster
run: kind delete cluster --name=e2e-tests
- name: Create k8s Kind Cluster v1.20.0
uses: helm/[email protected]
with:
Expand All @@ -37,7 +78,6 @@ jobs:
kind load --name e2e-tests docker-image ibmcom/varnish-controller:local
kind load --name e2e-tests docker-image ibmcom/varnish-metrics-exporter:local
- name: install operator
id: helm
run: helm install varnish-operator --debug --namespace=varnish-operator varnish-operator --wait --set container.imagePullPolicy=Never --set container.image=ibmcom/varnish-operator:local
- name: run tests
run: go test -count=1 ./tests #-count=1 is to disable tests caching.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ VARNISH_CONTROLLER_IMG ?= ${VARNISH_CONTROLLER_PUBLISH_IMG}-dev
VARNISH_METRICS_PUBLISH_IMG ?= varnish-metrics-exporter:${VERSION}
VARNISH_METRICS_IMG ?= ${VARNISH_METRICS_PUBLISH_IMG}-dev
NAMESPACE ?= "default"
CRD_OPTIONS ?= "crd:crdVersions=v1,trivialVersions=false"
CRD_OPTIONS ?= "crd:crdVersions=v1"

# all: test varnish-operator
all: test varnish-operator varnish-controller
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

277 changes: 257 additions & 20 deletions config/crd/bases/caching.ibm.com_varnishclusters.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ This can be done using the helm template configured to use your custom image:
docker build -t <image-name> -f Dockerfile .
docker push <image-name>
make manifests #make sure your helm charts are in sync with current CRD and RBAC definitions
helm install --name varnish-operator --namespace varnish-operator-system --set container.image=<image-name> ./varnish-operator
helm install varnish-operator --namespace varnish-operator-system --set container.image=<image-name> ./varnish-operator
```

Check the operator pod logs to make sure all works as expected:
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $ kubectl create ns varnish-operator
Install the operator:

```bash
$ helm install --name varnish-operator --namespace varnish-operator varnish-operator/varnish-operator
$ helm install varnish-operator --namespace varnish-operator varnish-operator/varnish-operator
```

You should see your operator pod up and running:
Expand Down
2 changes: 1 addition & 1 deletion docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $ helm repo update
### Install Varnish Operator

```bash
$ helm install --name varnish-operator --namespace varnish-operator varnish-operator/varnish-operator
$ helm install varnish-operator --namespace varnish-operator varnish-operator/varnish-operator
```

You should see your operator pod up and running:
Expand Down
17 changes: 11 additions & 6 deletions pkg/varnishcluster/controller/varnishcluster_headless_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,18 @@ func (r *ReconcileVarnishCluster) reconcileHeadlessService(ctx context.Context,
}
} else if err != nil {
return errors.Wrap(err, "could not get current state of Headless Service")
} else if !compare.EqualService(found, desired) {
logr.Infoc("Updating Headless Service", "diff", compare.DiffService(found, desired))
if err = r.Update(ctx, found); err != nil {
return errors.Wrap(err, "could not update Headless Service")
}
} else {
logr.Debugw("No updates for Headless Service")
desired.Spec.InternalTrafficPolicy = found.Spec.InternalTrafficPolicy
desired.Spec.IPFamilyPolicy = found.Spec.IPFamilyPolicy
desired.Spec.IPFamilies = found.Spec.IPFamilies
if !compare.EqualService(found, desired) {
logr.Infoc("Updating Headless Service", "diff", compare.DiffService(found, desired))
if err = r.Update(ctx, found); err != nil {
return errors.Wrap(err, "could not update Headless Service")
}
} else {
logr.Debugw("No updates for Headless Service")
}
}

return nil
Expand Down
4 changes: 3 additions & 1 deletion pkg/varnishcluster/controller/varnishcluster_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ func (r *ReconcileVarnishCluster) reconcileServiceGeneric(ctx context.Context, i
// ClusterIP is immutable once created, so always enforce the same as existing
desired.Spec.ClusterIP = found.Spec.ClusterIP
desired.Spec.ClusterIPs = found.Spec.ClusterIPs

desired.Spec.IPFamilies = found.Spec.IPFamilies
desired.Spec.IPFamilyPolicy = found.Spec.IPFamilyPolicy
desired.Spec.InternalTrafficPolicy = found.Spec.InternalTrafficPolicy
// use nodePort from the spec or the one allocated by Kubernetes
if desired.Spec.Type == v1.ServiceTypeLoadBalancer || desired.Spec.Type == v1.ServiceTypeNodePort {
inheritNodePorts(desired.Spec.Ports, found.Spec.Ports)
Expand Down
Loading

0 comments on commit 5d86ed1

Please sign in to comment.