Skip to content

Commit 7fc0344

Browse files
authored
Merge pull request #10 from awels/fix_deploy_to_external_cluster
Allow deployment to external cluster
2 parents f9f910a + a5ee8ad commit 7fc0344

File tree

8 files changed

+90
-5
lines changed

8 files changed

+90
-5
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,8 @@ go.work
2626
*.swo
2727
*~
2828

29+
#kustomize
30+
config/manager/kustomization.yaml
31+
2932
# kubevirtci
3033
_ci-configs/*

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ OPERATOR_SDK_VERSION ?= v1.40.0
5353
IMG ?= kubevirt-migration-controller:latest
5454

5555
DOCKER_REPO ?= localhost
56+
DEPLOYMENT_TARGET ?= default
5657

5758
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
5859
ifeq (,$(shell go env GOBIN))
@@ -199,7 +200,7 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
199200
build-installer: manifests generate kustomize ## Generate a consolidated YAML with CRDs and deployment.
200201
mkdir -p dist
201202
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
202-
$(KUSTOMIZE) build config/default > dist/install.yaml
203+
$(KUSTOMIZE) build config/$(DEPLOYMENT_TARGET) > dist/install.yaml
203204

204205
##@ Deployment
205206

@@ -219,11 +220,11 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified
219220
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
220221
@echo "Deploying controller to the K8s cluster specified in ~/.kube/config. MANIFEST_IMG: ${MANIFEST_IMG}"
221222
cd config/manager && $(KUSTOMIZE) edit set image controller=${MANIFEST_IMG}
222-
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -
223+
$(KUSTOMIZE) build config/$(DEPLOYMENT_TARGET) | $(KUBECTL) apply -f -
223224

224225
.PHONY: undeploy
225226
undeploy: kustomize ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
226-
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
227+
$(KUSTOMIZE) build config/$(DEPLOYMENT_TARGET) | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
227228

228229
##@ Dependencies
229230

cluster-sync/sync.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ else
2828
fi
2929
make deploy MANIFEST_IMG="${MANIFEST_IMG}"
3030

31+
if [[ "$KUBEVIRT_PROVIDER" != "external" ]]; then
3132
# Install CertManager
3233
_kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/${CERT_MANAGER_VERSION}/cert-manager.yaml
33-
_kubectl wait deployment.apps/cert-manager-webhook --for condition=Available --namespace cert-manager --timeout 5m
34+
_kubectl wait deployment.apps/cert-manager-webhook --for condition=Available --namespace cert-manager --timeout 5m
35+
fi

config/crd/kustomization.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
resources:
77
- bases/migrations.kubevirt.io_virtualmachinestoragemigrationplans.yaml
88
- bases/migrations.kubevirt.io_virtualmachinestoragemigrations.yaml
9-
- bases/route.openshift.io_routes.yaml
109
# +kubebuilder:scaffold:crdkustomizeresource
1110

1211
patches:
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This patch adds the args, volumes, and ports to allow the manager to use the metrics-server certs.
2+
3+
# Add the volumeMount for the metrics-server certs
4+
- op: add
5+
path: /spec/template/spec/containers/0/volumeMounts/-
6+
value:
7+
mountPath: /tmp/k8s-metrics-server/metrics-certs
8+
name: metrics-certs
9+
readOnly: true
10+
11+
# Add the --metrics-cert-path argument for the metrics server
12+
- op: add
13+
path: /spec/template/spec/containers/0/args/-
14+
value: --metrics-cert-path=/tmp/k8s-metrics-server/metrics-certs
15+
16+
# Add the metrics-server certs volume configuration
17+
- op: add
18+
path: /spec/template/spec/volumes/-
19+
value:
20+
name: metrics-certs
21+
secret:
22+
secretName: metrics-server-cert
23+
optional: false
24+
items:
25+
- key: ca.crt
26+
path: ca.crt
27+
- key: tls.crt
28+
path: tls.crt
29+
- key: tls.key
30+
path: tls.key
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Adds namespace to all resources.
2+
namespace: openshift-cnv
3+
4+
# Value of this field is prepended to the
5+
# names of all resources, e.g. a deployment named
6+
# "wordpress" becomes "alices-wordpress".
7+
# Note that it should also match with the prefix (text before '-') of the namespace
8+
# field above.
9+
namePrefix: kubevirt-migration-
10+
11+
# Labels to add to all resources and selectors.
12+
#labels:
13+
#- includeSelectors: true
14+
# pairs:
15+
# someName: someValue
16+
17+
resources:
18+
- ../crd
19+
- ../rbac
20+
- ../manager
21+
22+
# Uncomment the patches line if you enable Metrics
23+
patches:
24+
# [METRICS] The following patch will enable the metrics endpoint using HTTPS and the port :8443.
25+
# More info: https://book.kubebuilder.io/reference/metrics
26+
- path: manager_metrics_patch.yaml
27+
target:
28+
kind: Deployment
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This patch adds the args to allow exposing the metrics endpoint using HTTPS
2+
- op: add
3+
path: /spec/template/spec/containers/0/args/0
4+
value: --metrics-bind-address=:8443
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
labels:
5+
control-plane: controller
6+
app.kubernetes.io/name: kubevirt-migration-controller
7+
app.kubernetes.io/managed-by: kustomize
8+
name: controller-metrics-service
9+
namespace: system
10+
spec:
11+
ports:
12+
- name: https
13+
port: 8443
14+
protocol: TCP
15+
targetPort: 8443
16+
selector:
17+
control-plane: controller
18+
app.kubernetes.io/name: kubevirt-migration-controller

0 commit comments

Comments
 (0)