From 54678add1f83902ce35fc91306f86dc2aedb68b1 Mon Sep 17 00:00:00 2001 From: Victor Morales Date: Tue, 25 Apr 2023 21:02:40 -0700 Subject: [PATCH 1/3] Add ko support ko tool automates the processs to build and test go lang process. It provides support to KinD clusters as well as integrates easily with kustomize tool. This changes provides the `kind-deploy` target which covers the e2e provisioning process in a local cluster. Signed-off-by: Victor Morales --- free5gc-operator/Makefile | 22 ++++++++++++++++++++ free5gc-operator/config/manager/manager.yaml | 6 ++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/free5gc-operator/Makefile b/free5gc-operator/Makefile index b4a546b..dcb1c2a 100644 --- a/free5gc-operator/Makefile +++ b/free5gc-operator/Makefile @@ -171,6 +171,13 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} $(KUSTOMIZE) build config/default | $(KUBECTL) apply -f - +.PHONY: kind-deploy +kind-deploy: manifests kind kustomize ko ## Deploy controller to the KinD cluster specified in KIND_CLUSTER_NAME. + $(KIND) create cluster || : + $(KUBECTL) apply -f "https://raw.githubusercontent.com/k8snetworkplumbingwg/multus-cni/$(MULTUS_CNI_VERSION)/deployments/multus-daemonset-thick-plugin.yml" + $(KUBECTL) rollout status daemonset/kube-multus-ds -n kube-system --timeout=3m + $(KUSTOMIZE) build config/default | KO_DOCKER_REPO=kind.local $(KO) apply -f - + .PHONY: undeploy undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. $(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f - @@ -188,12 +195,17 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen ENVTEST ?= $(LOCALBIN)/setup-envtest KPT ?= $(LOCALBIN)/kpt KPTGEN ?= $(LOCALBIN)/kptgen +KO ?= $(LOCALBIN)/ko +KIND ?= $(LOCALBIN)/kind ## Tool Versions KUSTOMIZE_VERSION ?= v3.8.7 CONTROLLER_TOOLS_VERSION ?= v0.9.2 KPT_VERSION ?= main KPTGEN_VERSION ?= v0.0.9 +KO_VERSION ?= v0.13.0 +KIND_VERSION ?= v0.18.0 +MULTUS_CNI_VERSION ?= v3.9.3 KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" .PHONY: kustomize @@ -220,3 +232,13 @@ $(KPT): $(LOCALBIN) kptgen: $(KPTGEN) $(KPTGEN): $(LOCALBIN) test -s $(LOCALBIN)/kptgen || GOBIN=$(LOCALBIN) go install -v github.com/henderiw-kpt/kptgen@$(KPTGEN_VERSION) + +.PHONY: ko +ko: $(KO) ## Download ko locally if necessary. +$(KO): $(LOCALBIN) + test -s $(LOCALBIN)/ko || GOBIN=$(LOCALBIN) go install -v github.com/google/ko@$(KO_VERSION) + +.PHONY: kind +kind: $(KIND) ## Download kind locally if necessary. +$(KIND): $(LOCALBIN) + test -s $(LOCALBIN)/kind || GOBIN=$(LOCALBIN) go install -v sigs.k8s.io/kind@$(KIND_VERSION) diff --git a/free5gc-operator/config/manager/manager.yaml b/free5gc-operator/config/manager/manager.yaml index d2e2420..3086ad5 100644 --- a/free5gc-operator/config/manager/manager.yaml +++ b/free5gc-operator/config/manager/manager.yaml @@ -66,11 +66,9 @@ spec: # seccompProfile: # type: RuntimeDefault containers: - - command: - - /manager - args: + - args: - --leader-elect - image: controller:latest + image: ko://main.go name: manager securityContext: allowPrivilegeEscalation: false From 4b81278fe165e39b2e3e24998896be95cdf6cc66 Mon Sep 17 00:00:00 2001 From: Victor Morales Date: Tue, 25 Apr 2023 21:07:32 -0700 Subject: [PATCH 2/3] Add spellchecker Several typos can be catch from spellchecker tools. This change provides an automated way to validate typos on documentation. Signed-off-by: Victor Morales --- .gitignore | 1 + .spellcheck.yml | 21 ++++++++++ .wordlist.txt | 78 ++++++++++++++++++++++++++++++++++++++ free5gc-operator/README.md | 4 +- tox.ini | 14 +++++++ 5 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 .spellcheck.yml create mode 100644 .wordlist.txt create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..464ec3d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.dic diff --git a/.spellcheck.yml b/.spellcheck.yml new file mode 100644 index 0000000..e1d476b --- /dev/null +++ b/.spellcheck.yml @@ -0,0 +1,21 @@ +--- +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2023 +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +matrix: + - name: markdown + dictionary: + wordlists: + - .wordlist.txt + pipeline: + - pyspelling.filters.markdown: + sources: + - '**/*.md' + aspell: + ignore-case: true diff --git a/.wordlist.txt b/.wordlist.txt new file mode 100644 index 0000000..035c3b2 --- /dev/null +++ b/.wordlist.txt @@ -0,0 +1,78 @@ +adee +ae +AMF +apiextensions +auth +bec +cdb +CGO +clusterrole +clusterrolebinding +cmd +CNI +config +coverprofile +CRD +crds +customresourcedefinition +daemonset +df +dhcp +distroless +Dockerfile +dockerignore +ds +ebfaef +eca +ef +envtest +fb +fbdf +fc +fcf +fmt +gc +gcr +githubusercontent +GOARCH +GOBIN +golang +GOOS +headerFile +https +ipvlan +kube +kubebuilder +kubectl +kubernetes +kustomize +ljs +loopback +macvlan +Makefile +multus +namespace +Nephio +nonroot +portmap +pre +ptp +rbac +replicaset +rolebinding +roleName +rwxr +sbr +serviceaccount +sha +sigs +SMF +txt +UPF +upfdeployments +vlan +webhook +wjngx +WORKDIR +xr +XXXDeployment diff --git a/free5gc-operator/README.md b/free5gc-operator/README.md index 0e3ea54..52e21fd 100644 --- a/free5gc-operator/README.md +++ b/free5gc-operator/README.md @@ -64,7 +64,7 @@ make run ``` ### Deploy the controller -Change image varible in Makefile: +Change image variable in Makefile: ```sh REGISTRY ?= registry @@ -126,7 +126,7 @@ ff5700ec5418: Layer already exists latest: digest: sha256:3e86a217e906ebfaef66dc7363698e59576c928768105d303d25c59706a01b4d size: 2402 ``` -and finnaly deploy container to a kubernetes cluster +and finally deploy container to a kubernetes cluster ```sh $ make deploy diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..09c5dd5 --- /dev/null +++ b/tox.ini @@ -0,0 +1,14 @@ +[tox] +minversion = 1.6 +skipsdist = True +envlist = lint + +[testenv] +passenv = http_proxy,HTTP_PROXY,https_proxy,HTTPS_PROXY,no_proxy,NO_PROXY +usedevelop = False +install_command = pip install {opts} {packages} + +[testenv:spell] +deps = + pyspelling +commands = pyspelling -c .spellcheck.yml From c766ec3f13450e5d6c544a9e4d8fed16b7409ac8 Mon Sep 17 00:00:00 2001 From: Victor Morales Date: Tue, 25 Apr 2023 21:10:35 -0700 Subject: [PATCH 3/3] Refactor container runtime detection Signed-off-by: Victor Morales --- free5gc-operator/Makefile | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/free5gc-operator/Makefile b/free5gc-operator/Makefile index dcb1c2a..f0df765 100644 --- a/free5gc-operator/Makefile +++ b/free5gc-operator/Makefile @@ -6,12 +6,7 @@ TEST_COVERAGE_HTML_FILE=coverage_unit.html TEST_COVERAGE_FUNC_FILE=func_coverage.out # CONTAINER_RUNNABLE checks if tests and lint check can be run inside container. -PODMAN ?= $(shell podman -v > /dev/null 2>&1; echo $$?) -ifeq ($(PODMAN), 0) -CONTAINER_RUNTIME=podman -else -CONTAINER_RUNTIME=docker -endif +CONTAINER_RUNTIME ?= $(shell which podman 2> /dev/null || which docker 2> /dev/null || echo docker) CONTAINER_RUNNABLE ?= $(shell $(CONTAINER_RUNTIME) -v > /dev/null 2>&1; echo $$?) # Use microk8s if installed