Skip to content

Commit

Permalink
aberg/DEVOPS 247 (#3)
Browse files Browse the repository at this point in the history
* Move custom resource definitions to crds directory

* modified travis build conditions

* Initial commit for v0.8.0

* Bumped up versions of go, alpine, operator sdk, docker, cri-tool

* upgrade go in travis ci

* update dependencies

* code changes for upgraded dependencies

* fix unit tests

* make release-amd64 to build all 4 amd64 images

* v1alpha1 -> v1alpha2, kubefledged.k8s.io -> kubefledged.io

* ignore build binaries

* add labels to manifests

* updates to imagecache manifest

* update apigroup apiversion in validatingwebhook

* issue senthilrch#70 deploy-using-yaml: wait for webhook-server running

* issue senthilrch#66: upgrade crd api version to v1

* updates to helm chart & operator

* update clusterrole to list and watch

* update signer name in csr

* remove v1alpha1 cr

* issue senthilrch#70 add init container to wait for webhook-server

* helm chart fix webhook service name

* helm chart update

* fix chart apiVersion

* updated readme for helm chart installation

* updated name of helm operator cr

* fix issue senthilrch#75: workaround

* Ensure validating webhook configuration client config service name for the webhook server mataches the correct webhook service name

* Ensure validating webhook configuration client config service name for the webhook server mataches the correct webhook service name

* add init option to webhook server

* update manifests

* updated helm chart

* updated makefile and manifests

* updated helm operator

* makefile wait for operator ready

* get imagecache before updating status

* pre-install hook for validatingwebhookconfiguration

* fix golint errors

* modify refresh/purge annotation key to kubefledged.io/xxx

* cri-client-image name as env instead of cmd flag

* read busybox image from env

* use busybox image from gcr.io to overcome dockerhub ratelimiting

* fix issue senthilrch#89 change hostpath filetype to socket

* delete pre-install hook in "make remove-operator-and-kubefledged"

* add annotations to validatingwebhookconfiguration

* add "helm repo update" to readme

* continue processing job deletion when not found

* check if refresh-cache annotation exists

* add "helm repo update" to readme

* update helm chart to use release namespace

* update design proposal document

* expose helm parameters in operator CR

* document helm parameters

* update release version to v0.8.2

* set status to known when unable to fetch pod

* add check for image pull/delete status unknown

* update log messages

* deploy controller and operator to same namespace

* fix unit test errors

* restore Kubefledged CR during "remove-operator-and-kubefledged"

* Update README.md

* Update README.md

* Update design-proposal.md

* Update README.md

Co-authored-by: Diego Rodriguez <[email protected]>
Co-authored-by: Senthil Raja Chermapandian <[email protected]>
  • Loading branch information
3 people authored Sep 16, 2021
1 parent 59d4c2c commit c3c3be7
Show file tree
Hide file tree
Showing 85 changed files with 2,210 additions and 1,328 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# ignore build output
build/fledged
build/fledged-latest.tar.gz
build/kubefledged-controller
build/kubefledged-webhook-server
scp.sh
coverage.out
16 changes: 9 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dist: bionic
language: go
go:
- 1.14.2
- 1.16.4
services:
- docker
env:
Expand All @@ -12,22 +12,23 @@ before_install:
# https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository
- sudo apt-get remove docker docker-engine docker.io containerd runc
- sudo apt-get update
- sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y
- sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- sudo apt-get update
- sudo apt-get install docker-ce docker-ce-cli containerd.io -y
install:
# Install dependencies required for unit test coverage
- go get golang.org/x/tools/cmd/cover
- go get github.com/mattn/goveralls
- go get -u golang.org/x/lint/golint
stages:
# This stage builds controller and webhook-server images, performs tests in "hack" and runs unit tests with coverage
# This stage builds all four amd64 images, performs tests in "hack" and runs unit tests with coverage
- name: build_amd64
if: type = push
if: (type = push AND branch = develop) or (type = pull_request)
# This stage builds all four multi-arch images and pushes them to docker hub (only for PR builds)
- name: build_multiarch
if: type = pull_request
if: type = push and branch = master
# This stage is a placeholder for future (only for release tags)
- name: build_release
if: tag IS present
Expand All @@ -40,15 +41,16 @@ jobs:
- hack/verify-gofmt.sh
- hack/verify-golint.sh
- hack/verify-govet.sh
- echo "$DOCKERHUB_PSWD" | docker login --username "$DOCKERHUB_USER" --password-stdin
# BUILD_OUTPUT is left empty to indicate buildx to leave the built images in it's cache
- travis_wait 30 make BUILD_OUTPUT= controller-amd64 webhook-server-amd64
- travis_wait 30 make BUILD_OUTPUT= PROGRESS=plain release-amd64
- make test
- $(go env GOPATH | awk 'BEGIN{FS=":"} {print $1}')/bin/goveralls -coverprofile=coverage.out -service=travis-ci
- stage: build_multiarch
script:
- echo "$DOCKERHUB_PSWD" | docker login --username "$DOCKERHUB_USER" --password-stdin
# BUILD_OUTPUT=--push requests buildx to push the built images to docker hub
- travis_wait 60 make release
- travis_wait 60 make PROGRESS=plain release
- stage: build_release
script:
- echo "Release tag pushed. nothing to do!!"
92 changes: 52 additions & 40 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

.PHONY: clean clean-controller clean-cri-client clean-operator controller-amd64 controller-image cri-client-image operator-image build-images push-images test deploy update remove
.PHONY: clean clean-controller clean-cri-client clean-operator controller-amd64 controller-image cri-client-image operator-image build-images push-images test deploy update remove hack
# Default tag and architecture. Can be overridden
TAG?=$(shell git describe --tags --dirty)
ARCH?=amd64
Expand Down Expand Up @@ -43,27 +43,27 @@ ifndef OPERATOR_IMAGE_REPO
endif

ifndef RELEASE_VERSION
RELEASE_VERSION=v0.7.1
RELEASE_VERSION=v0.8.2
endif

ifndef DOCKER_VERSION
DOCKER_VERSION=19.03.8
DOCKER_VERSION=20.10.6
endif

ifndef CRICTL_VERSION
CRICTL_VERSION=v1.18.0
CRICTL_VERSION=v1.21.0
endif

ifndef GOLANG_VERSION
GOLANG_VERSION=1.14.2
GOLANG_VERSION=1.16.4
endif

ifndef ALPINE_VERSION
ALPINE_VERSION=3.11.6
ALPINE_VERSION=3.13.5
endif

ifndef OPERATORSDK_VERSION
OPERATORSDK_VERSION=v0.17.1
OPERATORSDK_VERSION=v1.9.0
endif

ifndef TARGET_PLATFORMS
Expand All @@ -78,8 +78,8 @@ ifndef BUILD_OUTPUT
BUILD_OUTPUT=--push
endif

ifndef OPERATOR_NAMESPACE
OPERATOR_NAMESPACE=kubefledged-operator
ifndef PROGRESS
PROGRESS=auto
endif

ifndef KUBEFLEDGED_NAMESPACE
Expand Down Expand Up @@ -121,7 +121,7 @@ clean-operator:
controller-image: clean-controller
docker buildx build --platform=${TARGET_PLATFORMS} -t ${CONTROLLER_IMAGE_REPO}:${RELEASE_VERSION} \
-t ${CONTROLLER_IMAGE_REPO}:latest -f build/Dockerfile.controller ${HTTP_PROXY_CONFIG} ${HTTPS_PROXY_CONFIG} \
--build-arg GOLANG_VERSION=${GOLANG_VERSION} --build-arg ALPINE_VERSION=${ALPINE_VERSION} --progress=plain ${BUILD_OUTPUT} .
--build-arg GOLANG_VERSION=${GOLANG_VERSION} --build-arg ALPINE_VERSION=${ALPINE_VERSION} --progress=${PROGRESS} ${BUILD_OUTPUT} .

controller-amd64: TARGET_PLATFORMS=linux/amd64
controller-amd64: install-buildx controller-image
Expand All @@ -135,7 +135,7 @@ controller-dev: clean-controller
webhook-server-image: clean-webhook-server
docker buildx build --platform=${TARGET_PLATFORMS} -t ${WEBHOOK_SERVER_IMAGE_REPO}:${RELEASE_VERSION} \
-t ${WEBHOOK_SERVER_IMAGE_REPO}:latest -f build/Dockerfile.webhook_server ${HTTP_PROXY_CONFIG} ${HTTPS_PROXY_CONFIG} \
--build-arg GOLANG_VERSION=${GOLANG_VERSION} --build-arg ALPINE_VERSION=${ALPINE_VERSION} --progress=plain ${BUILD_OUTPUT} .
--build-arg GOLANG_VERSION=${GOLANG_VERSION} --build-arg ALPINE_VERSION=${ALPINE_VERSION} --progress=${PROGRESS} ${BUILD_OUTPUT} .

webhook-server-amd64: TARGET_PLATFORMS=linux/amd64
webhook-server-amd64: install-buildx webhook-server-image
Expand All @@ -150,12 +150,21 @@ cri-client-image: clean-cri-client
docker buildx build --platform=${TARGET_PLATFORMS} -t ${CRI_CLIENT_IMAGE_REPO}:${RELEASE_VERSION} \
-t ${CRI_CLIENT_IMAGE_REPO}:latest -f build/Dockerfile.cri_client ${HTTP_PROXY_CONFIG} ${HTTPS_PROXY_CONFIG} \
--build-arg DOCKER_VERSION=${DOCKER_VERSION} --build-arg CRICTL_VERSION=${CRICTL_VERSION} \
--build-arg ALPINE_VERSION=${ALPINE_VERSION} --progress=plain ${BUILD_OUTPUT} .
--build-arg ALPINE_VERSION=${ALPINE_VERSION} --progress=${PROGRESS} ${BUILD_OUTPUT} .

cri-client-amd64: TARGET_PLATFORMS=linux/amd64
cri-client-amd64: install-buildx cri-client-image

operator-image: clean-operator
cd deploy/kubefledged-operator && \
docker buildx build --platform=${OPERATOR_TARGET_PLATFORMS} -t ${OPERATOR_IMAGE_REPO}:${RELEASE_VERSION} \
-t ${OPERATOR_IMAGE_REPO}:latest -f build/Dockerfile --build-arg OPERATORSDK_VERSION=${OPERATORSDK_VERSION} --progress=plain ${BUILD_OUTPUT} .
-t ${OPERATOR_IMAGE_REPO}:latest -f build/Dockerfile --build-arg OPERATORSDK_VERSION=${OPERATORSDK_VERSION} --progress=${PROGRESS} ${BUILD_OUTPUT} .

operator-amd64: TARGET_PLATFORMS=linux/amd64
operator-amd64: install-buildx operator-image

release-amd64: TARGET_PLATFORMS=linux/amd64
release-amd64: release

release: install-buildx controller-image webhook-server-image cri-client-image operator-image

Expand All @@ -170,38 +179,44 @@ test:
-rm -f coverage.out
bash hack/run-unit-tests.sh

hack:
bash hack/update-codegen.sh
bash hack/update-gofmt.sh
bash hack/verify-codegen.sh
bash hack/verify-gofmt.sh
bash hack/verify-golint.sh
bash hack/verify-govet.sh

deploy-using-yaml:
-kubectl apply -f deploy/kubefledged-namespace.yaml
bash deploy/webhook-create-signed-cert.sh
bash deploy/webhook-patch-ca-bundle.sh
kubectl apply -f deploy/kubefledged-crd.yaml
kubectl apply -f deploy/kubefledged-serviceaccount.yaml
kubectl apply -f deploy/kubefledged-clusterrole.yaml
kubectl apply -f deploy/kubefledged-clusterrolebinding.yaml
kubectl apply -f deploy/kubefledged-deployment-controller.yaml
-kubectl delete validatingwebhookconfigurations -l app=kubefledged
kubectl apply -f deploy/kubefledged-validatingwebhook.yaml
kubectl apply -f deploy/kubefledged-deployment-webhook-server.yaml
kubectl apply -f deploy/kubefledged-service-webhook-server.yaml
kubectl apply -f deploy/kubefledged-validatingwebhook.yaml
kubectl apply -f deploy/kubefledged-deployment-controller.yaml
kubectl rollout status deployment kubefledged-webhook-server -n kube-fledged --watch
kubectl rollout status deployment kubefledged-controller -n kube-fledged --watch

deploy-using-operator:
# Create the namespaces for operator and kubefledged
-kubectl create namespace ${OPERATOR_NAMESPACE}
# Create the namespace
-kubectl create namespace ${KUBEFLEDGED_NAMESPACE}
# Deploy the operator to a separate namespace
sed -i 's|{{OPERATOR_NAMESPACE}}|${OPERATOR_NAMESPACE}|g' deploy/kubefledged-operator/deploy/service_account.yaml
sed -i "s|{{OPERATOR_NAMESPACE}}|${OPERATOR_NAMESPACE}|g" deploy/kubefledged-operator/deploy/clusterrole_binding.yaml
sed -i "s|{{OPERATOR_NAMESPACE}}|${OPERATOR_NAMESPACE}|g" deploy/kubefledged-operator/deploy/operator.yaml
kubectl apply -f deploy/kubefledged-operator/deploy/crds/charts.helm.k8s.io_kubefledgeds_crd.yaml
# Deploy the operator
sed -i "s|{{KUBEFLEDGED_NAMESPACE}}|${KUBEFLEDGED_NAMESPACE}|g" deploy/kubefledged-operator/deploy/service_account.yaml
sed -i "s|{{KUBEFLEDGED_NAMESPACE}}|${KUBEFLEDGED_NAMESPACE}|g" deploy/kubefledged-operator/deploy/clusterrole_binding.yaml
sed -i "s|{{KUBEFLEDGED_NAMESPACE}}|${KUBEFLEDGED_NAMESPACE}|g" deploy/kubefledged-operator/deploy/operator.yaml
kubectl apply -f deploy/kubefledged-operator/deploy/crds/charts.helm.kubefledged.io_kubefledgeds_crd.yaml
kubectl apply -f deploy/kubefledged-operator/deploy/service_account.yaml
kubectl apply -f deploy/kubefledged-operator/deploy/clusterrole.yaml
kubectl apply -f deploy/kubefledged-operator/deploy/clusterrole_binding.yaml
kubectl apply -f deploy/kubefledged-operator/deploy/operator.yaml
# Deploy kube-fledged to a separate namespace
sed -i "s|{{OPERATOR_NAMESPACE}}|${OPERATOR_NAMESPACE}|g" deploy/kubefledged-operator/deploy/crds/charts.helm.k8s.io_v1alpha1_kubefledged_cr.yaml
sed -i "s|{{KUBEFLEDGED_NAMESPACE}}|${KUBEFLEDGED_NAMESPACE}|g" deploy/kubefledged-operator/deploy/crds/charts.helm.k8s.io_v1alpha1_kubefledged_cr.yaml
bash deploy/webhook-create-signed-cert.sh --namespace ${KUBEFLEDGED_NAMESPACE}
bash deploy/webhook-patch-ca-bundle.sh
kubectl apply -f deploy/kubefledged-operator/deploy/crds/charts.helm.k8s.io_v1alpha1_kubefledged_cr.yaml
# Deploy kube-fledged
sed -i "s|{{KUBEFLEDGED_NAMESPACE}}|${KUBEFLEDGED_NAMESPACE}|g" deploy/kubefledged-operator/deploy/crds/charts.helm.kubefledged.io_v1alpha2_kubefledged_cr.yaml
kubectl rollout status deployment kubefledged-operator -n ${KUBEFLEDGED_NAMESPACE} --watch
kubectl apply -f deploy/kubefledged-operator/deploy/crds/charts.helm.kubefledged.io_v1alpha2_kubefledged_cr.yaml

update:
kubectl scale deployment kubefledged-controller --replicas=0 -n kube-fledged
Expand All @@ -216,23 +231,20 @@ remove-kubefledged:
-kubectl delete -f deploy/kubefledged-clusterrole.yaml
-kubectl delete -f deploy/kubefledged-crd.yaml
-kubectl delete -f deploy/kubefledged-validatingwebhook.yaml
-git checkout deploy/kubefledged-validatingwebhook.yaml
-git checkout deploy/kubefledged-operator/deploy/crds/charts.helm.k8s.io_v1alpha1_kubefledged_cr.yaml

remove-operator-and-kubefledged:
# Remove kubefledged and the namespace
-kubectl delete -f deploy/kubefledged-operator/deploy/crds/charts.helm.k8s.io_v1alpha1_kubefledged_cr.yaml
-kubectl delete namespace ${KUBEFLEDGED_NAMESPACE}
-git checkout deploy/kubefledged-validatingwebhook.yaml
-git checkout deploy/kubefledged-operator/deploy/crds/charts.helm.k8s.io_v1alpha1_kubefledged_cr.yaml
# Remove kubefledged
-kubectl delete -f deploy/kubefledged-operator/deploy/crds/charts.helm.kubefledged.io_v1alpha2_kubefledged_cr.yaml
-kubectl delete validatingwebhookconfigurations -l app.kubernetes.io/name=kube-fledged
# Remove the kubefledged operator and the namespace
-kubectl delete -f deploy/kubefledged-operator/deploy/operator.yaml
-kubectl delete -f deploy/kubefledged-operator/deploy/clusterrole_binding.yaml
-kubectl delete -f deploy/kubefledged-operator/deploy/clusterrole.yaml
-kubectl delete -f deploy/kubefledged-operator/deploy/service_account.yaml
-kubectl delete -f deploy/kubefledged-operator/deploy/crds/charts.helm.k8s.io_kubefledgeds_crd.yaml
-kubectl delete namespace ${OPERATOR_NAMESPACE}
-kubectl delete -f deploy/kubefledged-operator/deploy/crds/charts.helm.kubefledged.io_kubefledgeds_crd.yaml
-kubectl delete namespace ${KUBEFLEDGED_NAMESPACE}
# Restore manifests
-git checkout deploy/kubefledged-operator/deploy/operator.yaml
-git checkout deploy/kubefledged-operator/deploy/clusterrole_binding.yaml
-git checkout deploy/kubefledged-operator/deploy/service_account.yaml

-git checkout deploy/kubefledged-operator/deploy/crds/charts.helm.kubefledged.io_v1alpha2_kubefledged_cr.yaml
Loading

0 comments on commit c3c3be7

Please sign in to comment.