Skip to content

Commit

Permalink
split controllers deploy (#617)
Browse files Browse the repository at this point in the history
Signed-off-by: Zhiwei Yin <[email protected]>
  • Loading branch information
zhiweiyin318 authored Jun 8, 2023
1 parent 629b9e0 commit 18e9354
Show file tree
Hide file tree
Showing 46 changed files with 334 additions and 178 deletions.
28 changes: 21 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,33 @@ deploy-hub:
deploy-klusterlet:
deploy/managedcluster/klusterlet/install.sh

deploy-ocm-controller: ensure-kustomize
cp deploy/foundation/hub/overlays/ocm-controller/kustomization.yaml deploy/foundation/hub/overlays/ocm-controller/kustomization.yaml.tmp
cd deploy/foundation/hub/overlays/ocm-controller && ../../../../../$(KUSTOMIZE) edit set image 'quay.io/stolostron/multicloud-manager'=$(FOUNDATION_IMAGE_NAME)
cp deploy/foundation/hub/overlays/ocm-controller/patch.yaml deploy/foundation/hub/overlays/ocm-controller/patch.yaml.tmp
$(SED_CMD) -i.tmp "s,quay.io/stolostron/multicloud-manager,$(FOUNDATION_IMAGE_NAME)," deploy/foundation/hub/overlays/ocm-controller/patch.yaml
$(KUSTOMIZE) build deploy/foundation/hub/overlays/ocm-controller | $(KUBECTL) apply -f -
mv deploy/foundation/hub/overlays/ocm-controller/kustomization.yaml.tmp deploy/foundation/hub/overlays/ocm-controller/kustomization.yaml
mv deploy/foundation/hub/overlays/ocm-controller/patch.yaml.tmp deploy/foundation/hub/overlays/ocm-controller/patch.yaml

deploy-foundation: ensure-kustomize
cp deploy/foundation/hub/kustomization.yaml deploy/foundation/hub/kustomization.yaml.tmp
cd deploy/foundation/hub && ../../../$(KUSTOMIZE) edit set image 'quay.io/stolostron/multicloud-manager'=$(FOUNDATION_IMAGE_NAME)
$(SED_CMD) -i.tmp "s,quay.io/stolostron/multicloud-manager,$(FOUNDATION_IMAGE_NAME)," deploy/foundation/hub/patches.yaml
$(KUSTOMIZE) build deploy/foundation/hub | $(KUBECTL) apply -f -
mv deploy/foundation/hub/kustomization.yaml.tmp deploy/foundation/hub/kustomization.yaml
mv deploy/foundation/hub/patches.yaml.tmp deploy/foundation/hub/patches.yaml
cp deploy/foundation/hub/overlays/foundation/kustomization.yaml deploy/foundation/hub/overlays/foundation/kustomization.yaml.tmp
cd deploy/foundation/hub/overlays/foundation && ../../../../../$(KUSTOMIZE) edit set image 'quay.io/stolostron/multicloud-manager'=$(FOUNDATION_IMAGE_NAME)
cp deploy/foundation/hub/overlays/foundation/patch.yaml deploy/foundation/hub/overlays/foundation/patch.yaml.tmp
$(SED_CMD) -i.tmp "s,quay.io/stolostron/multicloud-manager,$(FOUNDATION_IMAGE_NAME)," deploy/foundation/hub/overlays/foundation/patch.yaml
$(KUSTOMIZE) build deploy/foundation/hub/overlays/foundation | $(KUBECTL) apply -f -
mv deploy/foundation/hub/overlays/foundation/kustomization.yaml.tmp deploy/foundation/hub/overlays/foundation/kustomization.yaml
mv deploy/foundation/hub/overlays/foundation/patch.yaml.tmp deploy/foundation/hub/overlays/foundation/patch.yaml

clean-foundation-agent:
$(KUBECTL) get managedclusteraddons -A | grep work-manager | awk '{print $$1" "$$2}' | xargs -n 2 $(KUBECTL) delete managedclusteraddons -n

clean-foundation-hub:
$(KUBECTL) delete -k deploy/foundation/hub/resource
$(KUBECTL) delete -k deploy/foundation/hub/ocm-controller
$(KUBECTL) delete -k deploy/foundation/hub/ocm-proxyserver
$(KUBECTL) delete -k deploy/foundation/hub/ocm-webhook
$(KUBECTL) delete -k deploy/foundation/hub/rbac
$(KUBECTL) delete -k deploy/foundation/hub/crds

clean-foundation: clean-foundation-hub clean-foundation-agent

Expand Down
12 changes: 12 additions & 0 deletions deploy/foundation/hub/crds/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
resources:
- action.open-cluster-management.io_managedclusteractions.crd.yaml
- internal.open-cluster-management.io_managedclusterinfos.crd.yaml
- imageregistry.open-cluster-management.io_managedclusterimageregistries.crd.yaml
- view.open-cluster-management.io_managedclusterviews.crd.yaml
- hive.openshift.io_clusterclaims.yaml
- hive.openshift.io_clusterdeployments.yaml
- hive.openshift.io_clusterpools.yaml


apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
6 changes: 6 additions & 0 deletions deploy/foundation/hub/ocm-controller/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resources:
- clustermanagementaddon.yaml
- ocm-controller.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
49 changes: 49 additions & 0 deletions deploy/foundation/hub/ocm-controller/ocm-controller.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
kind: Deployment
apiVersion: apps/v1
metadata:
name: ocm-controller
namespace: open-cluster-management
labels:
app: ocm-controller
spec:
replicas: 1
selector:
matchLabels:
app: ocm-controller
template:
metadata:
labels:
app: ocm-controller
spec:
serviceAccountName: ocm-foundation-sa
containers:
- name: ocm-controller
image: quay.io/stolostron/multicloud-manager
imagePullPolicy: Always
args:
- "/controller"
- "--enable-agent-deploy=true"
livenessProbe:
failureThreshold: 3
httpGet:
path: /healthz
port: 8000
scheme: HTTP
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
readinessProbe:
failureThreshold: 3
httpGet:
path: /readyz
port: 8000
scheme: HTTP
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
memory: 4Gi
9 changes: 9 additions & 0 deletions deploy/foundation/hub/ocm-proxyserver/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resources:
- ocm-clusterview-api-svc-v1alpha1.yaml
- ocm-clusterview-api-svc.yaml
- ocm-proxyserver-api-svc.yaml
- ocm-proxyserver.yaml
- ocm-proxyserver-svc.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
57 changes: 57 additions & 0 deletions deploy/foundation/hub/ocm-proxyserver/ocm-proxyserver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
kind: Deployment
apiVersion: apps/v1
metadata:
name: ocm-proxyserver
namespace: open-cluster-management
labels:
app: ocm-proxyserver
spec:
replicas: 1
selector:
matchLabels:
app: ocm-proxyserver
template:
metadata:
labels:
app: ocm-proxyserver
spec:
serviceAccountName: ocm-foundation-sa
containers:
- name: ocm-proxyserver
image: quay.io/stolostron/multicloud-manager
imagePullPolicy: Always
args:
- "/proxyserver"
- "--secure-port=6443"
- "--tls-cert-file=/var/run/apiservice/tls.crt"
- "--tls-private-key-file=/var/run/apiservice/tls.key"
- "--agent-cafile=/var/run/klusterlet/ca.crt"
- "--agent-certfile=/var/run/klusterlet/tls.crt"
- "--agent-keyfile=/var/run/klusterlet/tls.key"
volumeMounts:
- mountPath: /var/run/klusterlet
name: klusterlet-certs
- mountPath: /var/run/apiservice
name: apiservice-certs
livenessProbe:
httpGet:
path: /healthz
scheme: HTTPS
port: 6443
initialDelaySeconds: 2
periodSeconds: 10
readinessProbe:
httpGet:
path: /healthz
scheme: HTTPS
port: 6443
initialDelaySeconds: 2
volumes:
- name: klusterlet-certs
secret:
defaultMode: 420
secretName: ocm-klusterlet-self-signed-secrets
- name: apiservice-certs
secret:
defaultMode: 420
secretName: ocm-proxyserver
9 changes: 9 additions & 0 deletions deploy/foundation/hub/ocm-webhook/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resources:
- ocm-webhook.yaml
- ocm-webhook-svc.yaml
- webhook-mutating-config.yaml
- webhook-validating-config.yaml


apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ spec:
volumeMounts:
- mountPath: /var/run/ocm-webhook
name: webhook-cert
serviceAccountName: foundation-hub-sa
serviceAccountName: ocm-foundation-sa
volumes:
- name: webhook-cert
secret:
Expand Down
55 changes: 55 additions & 0 deletions deploy/foundation/hub/ocm-webhook/webhook-mutating-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright Contributors to the Open Cluster Management project

apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
annotations:
service.beta.openshift.io/inject-cabundle: "true"
labels:
app: ocm-webhook
name: ocm-mutating-webhook
webhooks:
- admissionReviewVersions:
- v1
clientConfig:
service:
name: ocm-webhook
namespace: open-cluster-management
path: /mutating
port: 443
name: ocm.mutating.webhook.admission.open-cluster-management.io
sideEffects: None
rules:
- apiGroups:
- apps.open-cluster-management.io
apiVersions:
- v1
operations:
- CREATE
resources:
- deployables
- channels
- subscriptions
- placementrules
scope: '*'
- apiGroups:
- app.k8s.io
apiVersions:
- v1beta1
operations:
- CREATE
- UPDATE
resources:
- applications
scope: '*'
- apiGroups:
- hive.openshift.io
operations:
- CREATE
apiVersions:
- "v1"
resources:
- clusterdeployments
- clusterpools
- clusterclaims
scope: '*'
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Copyright Contributors to the Open Cluster Management project

apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
Expand Down
19 changes: 19 additions & 0 deletions deploy/foundation/hub/overlays/foundation/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
resources:
- ../../crds
- ../../rbac
- ../../ocm-controller
- ../../ocm-proxyserver
- ../../ocm-webhook


images:
- name: quay.io/stolostron/multicloud-manager
newName: quay.io/stolostron/multicloud-manager
newTag: latest


patchesStrategicMerge:
- patch.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
resources:
- resources
- ../../crds
- ../../rbac
- ../../ocm-controller


images:
Expand All @@ -9,7 +11,7 @@ images:


patchesStrategicMerge:
- patches.yaml
- patch.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
14 changes: 14 additions & 0 deletions deploy/foundation/hub/overlays/ocm-controller/patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
kind: Deployment
apiVersion: apps/v1
metadata:
name: ocm-controller
namespace: open-cluster-management
spec:
template:
spec:
containers:
- name: ocm-controller
args:
- "/controller"
- "--enable-agent-deploy=true"
- "--agent-addon-image=quay.io/stolostron/multicloud-manager"
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ rules:
- apiGroups: ["proxy.open-cluster-management.io"]
resources: ["clusterstatuses/aggregator"]
verbs: ["get", "create"]
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
verbs: ["get", "list", "watch", "update","create","patch"]
Loading

0 comments on commit 18e9354

Please sign in to comment.