Skip to content

Commit

Permalink
Merge pull request #444 from OpenLiberty/auto-generate-kustomize-arti…
Browse files Browse the repository at this point in the history
…facts

Added auto generation for kustomize artifacts
  • Loading branch information
BradleyMayo authored Jul 18, 2023
2 parents 3934000 + 1bcf6a1 commit c85ceb0
Show file tree
Hide file tree
Showing 8 changed files with 330 additions and 162 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ bundle: manifests setup kustomize ## Generate bundle manifests and metadata, the
$(KUSTOMIZE) build config/kubectl/rbac-watch-all -o internal/deploy/kubectl/openliberty-app-rbac-watch-all.yaml
$(KUSTOMIZE) build config/kubectl/rbac-watch-another -o internal/deploy/kubectl/openliberty-app-rbac-watch-another.yaml

$(KUSTOMIZE) build config/kustomize/watch-all -o internal/deploy/kustomize/daily/overlays/watch-all-namespaces/cluster-roles.yaml
$(KUSTOMIZE) build config/kustomize/watch-another -o internal/deploy/kustomize/daily/overlays/watch-another-namespace/olo-watched-ns/watched-roles.yaml

operator-sdk bundle validate ./bundle

.PHONY: fmt
Expand Down
93 changes: 93 additions & 0 deletions config/kustomize/watch-all/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../rbac

# Labels to add to all resources and selectors.
commonLabels:
app.kubernetes.io/instance: open-liberty-operator
app.kubernetes.io/name: open-liberty-operator

patches:
- path: patches/delete-service-account.yaml
target:
kind: ServiceAccount

patchesJson6902:
- target:
namespace: open-liberty-operator
name: .*
patch: |-
- op: remove
path: /metadata/namespace
- target:
kind: Role
name: .*
patch: |-
- op: replace
path: /kind
value: ClusterRole
- target:
kind: RoleBinding
name: .*
patch: |-
- op: replace
path: /kind
value: ClusterRoleBinding
- target:
kind: ClusterRoleBinding
name: .*
patch: |-
- op: replace
path: /subjects/0/name
value: olo-controller-manager
- op: replace
path: /subjects/0/namespace
value: OPEN_LIBERTY_OPERATOR_NAMESPACE
- op: replace
path: /roleRef/kind
value: ClusterRole
- target:
kind: ClusterRoleBinding
name: leader-election-rolebinding
patch: |-
- op: replace
path: /roleRef/name
value: olo-leader-election-cluster-role
- op: replace
path: /metadata/name
value: olo-leader-election-cluster-rolebinding
- target:
kind: ClusterRoleBinding
name: manager-rolebinding
patch: |-
- op: replace
path: /metadata/name
value: olo-manager-cluster-rolebinding
- op: replace
path: /roleRef/name
value: olo-manager-cluster-role
- target:
kind: ClusterRole
name: manager-role
patch: |-
- op: replace
path: /metadata/name
value: olo-manager-cluster-role
- op: add
path: /rules/-
value: {"apiGroups":[""],"resources":["namespaces"],"verbs":["get","list","watch"]}
- target:
kind: ClusterRoleBinding
name: .*
patch: |-
- op: replace
path: /subjects/0/namespace
value: open-liberty
- target:
kind: ClusterRole
name: leader-election-role
patch: |-
- op: replace
path: /metadata/name
value: olo-leader-election-cluster-role
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$patch: delete
apiVersion: v1
kind: ServiceAccount
metadata:
name: wlo-controller-manager
62 changes: 62 additions & 0 deletions config/kustomize/watch-another/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../rbac

namespace: olo-watched-ns

# Labels to add to all resources and selectors.
commonLabels:
app.kubernetes.io/instance: open-liberty-operator
app.kubernetes.io/name: open-liberty-operator

patches:
- path: patches/delete-service-account.yaml
target:
kind: ServiceAccount

patchesJson6902:
- target:
kind: RoleBinding
name: manager-rolebinding
patch: |-
- op: replace
path: /metadata/name
value: olo-watched-rolebinding
- op: replace
path: /roleRef/name
value: olo-watched-role
- target:
kind: RoleBinding
name: leader-election-rolebinding
patch: |-
- op: replace
path: /metadata/name
value: olo-leader-election-watched-rolebinding
- op: replace
path: /roleRef/name
value: olo-leader-election-watched-role
- target:
kind: RoleBinding
name: .*
patch: |-
- op: replace
path: /subjects/0/namespace
value: olo-ns
- op: replace
path: /subjects/0/name
value: olo-controller-manager
- target:
kind: Role
name: leader-election-role
patch: |-
- op: replace
path: /metadata/name
value: olo-leader-election-watched-role
- target:
kind: Role
name: manager-role
patch: |-
- op: replace
path: /metadata/name
value: olo-watched-role
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$patch: delete
apiVersion: v1
kind: ServiceAccount
metadata:
name: wlo-controller-manager
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ spec:
fieldPath: metadata.namespace
- name: RELATED_IMAGE_LIBERTY_SAMPLE_APP
value: icr.io/appcafe/open-liberty/samples/getting-started@sha256:d3c67c4a15c97b0fb82f9ef4a2ccf474232b878787e9eea39af75a3ac78469e3
image: icr.io/appcafe/open-liberty-operator:daily
image: icr.io/appcafe/open-liberty-operator:1.2.1
livenessProbe:
failureThreshold: 3
httpGet:
Expand Down
Loading

0 comments on commit c85ceb0

Please sign in to comment.