#33 Improve docs how to develop with a remote k8s cluster
This commit is contained in:
parent
e441c746d1
commit
0b03b85cf0
20
Makefile
20
Makefile
|
|
@ -152,19 +152,19 @@ CURRENT_DIRECTORY := $(shell pwd)
|
||||||
e2e: build docker-build ## Runs e2e tests, you can use EXTRA_ARGS
|
e2e: build docker-build ## Runs e2e tests, you can use EXTRA_ARGS
|
||||||
@echo "+ $@"
|
@echo "+ $@"
|
||||||
@echo "Docker image: $(DOCKER_REGISTRY):$(GITCOMMIT)"
|
@echo "Docker image: $(DOCKER_REGISTRY):$(GITCOMMIT)"
|
||||||
kubectl config use-context $(ENVIRONMENT)
|
kubectl config use-context $(KUBECTL_CONTEXT)
|
||||||
cp deploy/service_account.yaml deploy/namespace-init.yaml
|
cp deploy/service_account.yaml deploy/namespace-init.yaml
|
||||||
cat deploy/role.yaml >> deploy/namespace-init.yaml
|
cat deploy/role.yaml >> deploy/namespace-init.yaml
|
||||||
cat deploy/role_binding.yaml >> deploy/namespace-init.yaml
|
cat deploy/role_binding.yaml >> deploy/namespace-init.yaml
|
||||||
cat deploy/operator.yaml >> deploy/namespace-init.yaml
|
cat deploy/operator.yaml >> deploy/namespace-init.yaml
|
||||||
sed -i 's|\(image:\).*|\1 $(DOCKER_REGISTRY):$(GITCOMMIT)|g' deploy/namespace-init.yaml
|
sed -i 's|\(image:\).*|\1 $(DOCKER_REGISTRY):$(GITCOMMIT)|g' deploy/namespace-init.yaml
|
||||||
ifeq ($(ENVIRONMENT),minikube)
|
ifeq ($(KUBECTL_CONTEXT),minikube)
|
||||||
sed -i 's|\(imagePullPolicy\): IfNotPresent|\1: Never|g' deploy/namespace-init.yaml
|
sed -i 's|\(imagePullPolicy\): IfNotPresent|\1: Never|g' deploy/namespace-init.yaml
|
||||||
sed -i 's|\(args:\).*|\1\ ["--minikube"\]|' deploy/namespace-init.yaml
|
sed -i 's|\(args:\).*|\1\ ["--minikube"\]|' deploy/namespace-init.yaml
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@RUNNING_TESTS=1 go test -parallel=1 "./test/e2e/" -tags "$(BUILDTAGS) cgo" -v -timeout 30m -run "$(E2E_TEST_SELECTOR)" \
|
@RUNNING_TESTS=1 go test -parallel=1 "./test/e2e/" -tags "$(BUILDTAGS) cgo" -v -timeout 30m -run "$(E2E_TEST_SELECTOR)" \
|
||||||
-root=$(CURRENT_DIRECTORY) -kubeconfig=$(HOME)/.kube/config -globalMan deploy/crds/jenkins_v1alpha2_jenkins_crd.yaml -namespacedMan deploy/namespace-init.yaml $(EXTRA_ARGS)
|
-root=$(CURRENT_DIRECTORY) -kubeconfig=$(HOME)/.kube/config -globalMan deploy/crds/jenkins_$(API_VERSION)_jenkins_crd.yaml -namespacedMan deploy/namespace-init.yaml $(EXTRA_ARGS)
|
||||||
|
|
||||||
.PHONY: vet
|
.PHONY: vet
|
||||||
vet: ## Verifies `go vet` passes
|
vet: ## Verifies `go vet` passes
|
||||||
|
|
@ -204,10 +204,14 @@ install: ## Installs the executable
|
||||||
go install -tags "$(BUILDTAGS)" ${GO_LDFLAGS} $(BUILD_PATH)
|
go install -tags "$(BUILDTAGS)" ${GO_LDFLAGS} $(BUILD_PATH)
|
||||||
|
|
||||||
.PHONY: run
|
.PHONY: run
|
||||||
run: ## Run the executable, you can use EXTRA_ARGS
|
run: export WATCH_NAMESPACE = $(NAMESPACE)
|
||||||
|
run: export OPERATOR_NAME = $(NAME)
|
||||||
|
run: build ## Run the executable, you can use EXTRA_ARGS
|
||||||
@echo "+ $@"
|
@echo "+ $@"
|
||||||
kubectl config use-context $(ENVIRONMENT)
|
kubectl apply -f deploy/crds/jenkins_$(API_VERSION)_jenkins_crd.yaml
|
||||||
go run -tags "$(BUILDTAGS)" ${GO_LDFLAGS} $(BUILD_PATH)/main.go $(ARGS)
|
kubectl config use-context $(KUBECTL_CONTEXT)
|
||||||
|
@echo "Watching '$(WATCH_NAMESPACE)' namespace"
|
||||||
|
build/_output/bin/jenkins-operator $(EXTRA_ARGS)
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean: ## Cleanup any build binaries or packages
|
clean: ## Cleanup any build binaries or packages
|
||||||
|
|
@ -312,10 +316,10 @@ docker-run: ## Run the container in docker, you can use EXTRA_ARGS
|
||||||
.PHONY: minikube-run
|
.PHONY: minikube-run
|
||||||
minikube-run: export WATCH_NAMESPACE = $(NAMESPACE)
|
minikube-run: export WATCH_NAMESPACE = $(NAMESPACE)
|
||||||
minikube-run: export OPERATOR_NAME = $(NAME)
|
minikube-run: export OPERATOR_NAME = $(NAME)
|
||||||
minikube-run: minikube-start ## Run the operator locally and use minikube as Kubernetes cluster, you can use EXTRA_ARGS
|
minikube-run: minikube-start build ## Run the operator locally and use minikube as Kubernetes cluster, you can use EXTRA_ARGS
|
||||||
@echo "+ $@"
|
@echo "+ $@"
|
||||||
kubectl config use-context minikube
|
kubectl config use-context minikube
|
||||||
kubectl apply -f deploy/crds/jenkins_v1alpha2_jenkins_crd.yaml
|
kubectl apply -f deploy/crds/jenkins_$(API_VERSION)_jenkins_crd.yaml
|
||||||
@echo "Watching '$(WATCH_NAMESPACE)' namespace"
|
@echo "Watching '$(WATCH_NAMESPACE)' namespace"
|
||||||
build/_output/bin/jenkins-operator $(EXTRA_ARGS)
|
build/_output/bin/jenkins-operator $(EXTRA_ARGS)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,6 @@ NAMESPACE=default
|
||||||
API_VERSION=v1alpha2
|
API_VERSION=v1alpha2
|
||||||
MINIKUBE_KUBERNETES_VERSION=v1.12.9
|
MINIKUBE_KUBERNETES_VERSION=v1.12.9
|
||||||
MINIKUBE_DRIVER=virtualbox
|
MINIKUBE_DRIVER=virtualbox
|
||||||
ENVIRONMENT=minikube
|
KUBECTL_CONTEXT=minikube
|
||||||
ALL_IN_ONE_DEPLOY_FILE_PREFIX=all-in-one
|
ALL_IN_ONE_DEPLOY_FILE_PREFIX=all-in-one
|
||||||
GEN_CRD_API=gen-crd-api-reference-docs
|
GEN_CRD_API=gen-crd-api-reference-docs
|
||||||
|
|
@ -21,12 +21,12 @@ cd kubernetes-operator
|
||||||
make go-dependencies
|
make go-dependencies
|
||||||
```
|
```
|
||||||
|
|
||||||
## Build and run
|
## Build and run with a minikube
|
||||||
|
|
||||||
Build and run **jenkins-operator** locally:
|
Build and run **jenkins-operator** locally:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
make build && make minikube-run EXTRA_ARGS='--minikube --local'
|
make minikube-run EXTRA_ARGS='--minikube --local'
|
||||||
```
|
```
|
||||||
|
|
||||||
Once minikube and **jenkins-operator** are up and running, apply Jenkins custom resource:
|
Once minikube and **jenkins-operator** are up and running, apply Jenkins custom resource:
|
||||||
|
|
@ -37,18 +37,20 @@ kubectl get jenkins -o yaml
|
||||||
kubectl get po
|
kubectl get po
|
||||||
```
|
```
|
||||||
|
|
||||||
## Build and run with a remote cluster
|
## Build and run with a remote Kubernetes cluster
|
||||||
|
|
||||||
|
You can also run the controller locally and make it listen to a remote Kubernetes server.
|
||||||
|
|
||||||
If you are using a Linux development environment, you can also run the controller locally and make it listen to a remote
|
|
||||||
server.
|
|
||||||
```bash
|
```bash
|
||||||
export KUBECONFIG=$HOME/.crc/cache/crc_libvirt_4.1.0/kubeconfig
|
make run NAMESPACE=default KUBECTL_CONTEXT=remote-k8s EXTRA_ARGS='--kubeconfig ~/.kube/config'
|
||||||
kubectl apply -f deploy/crds/jenkins_v1alpha2_jenkins_crd.yaml
|
|
||||||
```
|
```
|
||||||
|
|
||||||
You can then build and run the controller locally and make it connect to your server:
|
Once minikube and **jenkins-operator** are up and running, apply Jenkins custom resource:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
make build && OPERATOR_NAME=jenkins-operator WATCH_NAMESPACE=default build/_output/bin/jenkins-operator --kubeconfig $KUBECONFIG
|
kubectl --context remote-k8s --namespace defaut apply -f deploy/crds/jenkins_v1alpha2_jenkins_cr.yaml
|
||||||
|
kubectl --context remote-k8s --namespace defaut get jenkins -o yaml
|
||||||
|
kubectl --context remote-k8s --namespace defaut get po
|
||||||
```
|
```
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,14 @@
|
||||||
|
|
||||||
This document explains how to install the Go tools used by the development process.
|
This document explains how to install the Go tools used by the development process.
|
||||||
|
|
||||||
|
## Configure environment variables
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export GOPATH=/home/go # example value
|
||||||
|
export GOROOT=/usr/lib/go-1.12 # example value
|
||||||
|
export PATH=$GOPATH/bin:$PATH
|
||||||
|
```
|
||||||
|
|
||||||
## goimports
|
## goimports
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue