From 23a576ba5b3950c1391f3650428235cda55157fa Mon Sep 17 00:00:00 2001 From: Sebastian Vargas Date: Tue, 11 Jun 2024 22:13:33 +0100 Subject: [PATCH] feat: Delete legacy manifests generation approach Co-Authored-By: Alby Hernandez --- Makefile | 10 +- README.md | 14 +- deploy/clusterrole/replika-manager-role.yaml | 57 ------- .../clusterrole/replika-metrics-reader.yaml | 17 -- deploy/clusterrole/replika-proxy-role.yaml | 25 --- .../replika-manager-rolebinding.yaml | 20 --- .../replika-proxy-rolebinding.yaml | 20 --- .../replikas-replika-prosimcorp-com.yaml | 154 ------------------ .../replika-controller-manager.yaml | 106 ------------ deploy/kustomization.yaml | 15 -- deploy/namespace/replika.yaml | 13 -- deploy/role/replika-leader-election-role.yaml | 45 ----- .../replika-leader-election-rolebinding.yaml | 21 --- ...ka-controller-manager-metrics-service.yaml | 24 --- .../replika-controller-manager.yaml | 13 -- 15 files changed, 13 insertions(+), 541 deletions(-) delete mode 100644 deploy/clusterrole/replika-manager-role.yaml delete mode 100644 deploy/clusterrole/replika-metrics-reader.yaml delete mode 100644 deploy/clusterrole/replika-proxy-role.yaml delete mode 100644 deploy/clusterrolebinding/replika-manager-rolebinding.yaml delete mode 100644 deploy/clusterrolebinding/replika-proxy-rolebinding.yaml delete mode 100644 deploy/customresourcedefinition/replikas-replika-prosimcorp-com.yaml delete mode 100644 deploy/deployment/replika-controller-manager.yaml delete mode 100644 deploy/kustomization.yaml delete mode 100644 deploy/namespace/replika.yaml delete mode 100644 deploy/role/replika-leader-election-role.yaml delete mode 100644 deploy/rolebinding/replika-leader-election-rolebinding.yaml delete mode 100644 deploy/service/replika-controller-manager-metrics-service.yaml delete mode 100644 deploy/serviceaccount/replika-controller-manager.yaml diff --git a/Makefile b/Makefile index 889b1c6..d7f74ce 100644 --- a/Makefile +++ b/Makefile @@ -96,15 +96,11 @@ docker-buildx: test ## Build and push docker image for the manager for cross-pla - docker buildx rm project-v3-builder rm Dockerfile.cross -.PHONY: kustomization-build -kustomization-build: manifests kustomize kubectl-slice ## Generate the manifests to package them later in the way you want. +.PHONY: bundle-build +bundle-build: manifests kustomize ## Generate the manifests bundle to package them later in the way you want. cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} - rm -rf deploy/* mkdir -p deploy - $(KUSTOMIZE) build config/default > deploy/manifests.yaml - $(KUBECTL_SLICE) --input-file=deploy/manifests.yaml --output-dir=deploy --template="{{.kind|lower}}/{{.metadata.name|dottodash}}.yaml" - @rm deploy/manifests.yaml || true - cd deploy && $(KUSTOMIZE) create --autodetect --recursive + $(KUSTOMIZE) build config/default > deploy/bundle.yaml ##@ Deployment diff --git a/README.md b/README.md index e0dfdb1..6e63add 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # Replika +> **ATTENTION:** From v0.4.0+ bundled Kubernetes deployment manifests are built and uploaded to the releases. +> We do this to keep them atomic between versions. Due to this, `deploy` directory will be removed from repository. +> Please, read [related section](#deployment) + ## Description A Kubernetes operator to replicate a resource across namespaces @@ -40,9 +44,11 @@ the tag of the version you want to deploy as follows: apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -- https://github.com/prosimcorp/replika//deploy/?ref=main +- https://github.com/prosimcorp/replika/releases/download/v0.4.0/bundle.yaml ``` +> 🧚🏼 **Hey, listen! If you prefer to deploy using Helm, go to the [Helm registry](https://github.com/prosimcorp/helm-charts)** + ## RBAC We designed the operator to be able to replicate any kind of resource in a Kubernetes cluster, but by design, Kubernetes @@ -88,7 +94,7 @@ subjects: apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - - https://github.com/prosimcorp/replika//deploy/?ref=main + - https://github.com/prosimcorp/replika/releases/download/v0.4.0/bundle.yaml # Add your custom resources - clusterRole-replika-custom-resources.yaml @@ -193,7 +199,7 @@ the process, the steps are described in the following recipe: ```console export VERSION="0.0.1" - export IMG="prosimcorp/replika:v$VERSION" + export IMG="ghcr.io/prosimcorp/replika:v$VERSION" ``` 3. Generate and push the Docker image (published on Docker Hub). @@ -205,7 +211,7 @@ the process, the steps are described in the following recipe: 4. Generate the manifests for deployments using Kustomize ```console - make kustomization-build + make bundle-build ``` ## How to collaborate diff --git a/deploy/clusterrole/replika-manager-role.yaml b/deploy/clusterrole/replika-manager-role.yaml deleted file mode 100644 index 9495f3b..0000000 --- a/deploy/clusterrole/replika-manager-role.yaml +++ /dev/null @@ -1,57 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - creationTimestamp: null - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: replika - name: replika-manager-role -rules: -- apiGroups: - - "" - resources: - - configmaps - - secrets - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - "" - resources: - - namespaces - verbs: - - get - - list - - watch -- apiGroups: - - replika.prosimcorp.com - resources: - - replikas - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - replika.prosimcorp.com - resources: - - replikas/finalizers - verbs: - - update -- apiGroups: - - replika.prosimcorp.com - resources: - - replikas/status - verbs: - - get - - patch - - update - diff --git a/deploy/clusterrole/replika-metrics-reader.yaml b/deploy/clusterrole/replika-metrics-reader.yaml deleted file mode 100644 index e0e7a8c..0000000 --- a/deploy/clusterrole/replika-metrics-reader.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/component: kube-rbac-proxy - app.kubernetes.io/created-by: replika - app.kubernetes.io/instance: metrics-reader - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: replika - app.kubernetes.io/part-of: replika - name: replika-metrics-reader -rules: -- nonResourceURLs: - - /metrics - verbs: - - get - diff --git a/deploy/clusterrole/replika-proxy-role.yaml b/deploy/clusterrole/replika-proxy-role.yaml deleted file mode 100644 index 379e16a..0000000 --- a/deploy/clusterrole/replika-proxy-role.yaml +++ /dev/null @@ -1,25 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/component: kube-rbac-proxy - app.kubernetes.io/created-by: replika - app.kubernetes.io/instance: proxy-role - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: replika - app.kubernetes.io/part-of: replika - name: replika-proxy-role -rules: -- apiGroups: - - authentication.k8s.io - resources: - - tokenreviews - verbs: - - create -- apiGroups: - - authorization.k8s.io - resources: - - subjectaccessreviews - verbs: - - create - diff --git a/deploy/clusterrolebinding/replika-manager-rolebinding.yaml b/deploy/clusterrolebinding/replika-manager-rolebinding.yaml deleted file mode 100644 index 256035b..0000000 --- a/deploy/clusterrolebinding/replika-manager-rolebinding.yaml +++ /dev/null @@ -1,20 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - labels: - app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: replika - app.kubernetes.io/instance: manager-rolebinding - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: replika - app.kubernetes.io/part-of: replika - name: replika-manager-rolebinding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: replika-manager-role -subjects: -- kind: ServiceAccount - name: replika-controller-manager - namespace: replika - diff --git a/deploy/clusterrolebinding/replika-proxy-rolebinding.yaml b/deploy/clusterrolebinding/replika-proxy-rolebinding.yaml deleted file mode 100644 index 29b6d10..0000000 --- a/deploy/clusterrolebinding/replika-proxy-rolebinding.yaml +++ /dev/null @@ -1,20 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - labels: - app.kubernetes.io/component: kube-rbac-proxy - app.kubernetes.io/created-by: replika - app.kubernetes.io/instance: proxy-rolebinding - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: replika - app.kubernetes.io/part-of: replika - name: replika-proxy-rolebinding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: replika-proxy-role -subjects: -- kind: ServiceAccount - name: replika-controller-manager - namespace: replika - diff --git a/deploy/customresourcedefinition/replikas-replika-prosimcorp-com.yaml b/deploy/customresourcedefinition/replikas-replika-prosimcorp-com.yaml deleted file mode 100644 index f2f833f..0000000 --- a/deploy/customresourcedefinition/replikas-replika-prosimcorp-com.yaml +++ /dev/null @@ -1,154 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.10.0 - creationTimestamp: null - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: replika - name: replikas.replika.prosimcorp.com -spec: - group: replika.prosimcorp.com - names: - categories: - - replikas - kind: Replika - listKind: ReplikaList - plural: replikas - singular: replika - scope: Namespaced - versions: - - additionalPrinterColumns: - - jsonPath: .status.conditions[?(@.type=="SourceSynced")].status - name: Ready - type: string - - jsonPath: .status.conditions[?(@.type=="SourceSynced")].reason - name: Status - type: string - - jsonPath: .metadata.creationTimestamp - name: Age - type: date - name: v1beta1 - schema: - openAPIV3Schema: - description: Replika is the Schema for the each Replika CR - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: ReplikaSpec defines the desired state of a Replika - properties: - source: - description: ReplikaSourceSpec define the source resource - properties: - group: - type: string - kind: - type: string - name: - type: string - namespace: - type: string - version: - type: string - required: - - group - - kind - - name - - version - type: object - synchronization: - description: SynchronizationSpec defines the behavior of synchronization - properties: - time: - type: string - required: - - time - type: object - target: - description: ReplikaTargetSpec defines the target [...] - properties: - namespaces: - description: ReplikaTargetNamespacesSpec defines the spec of the target namespaces section of a Replika - properties: - excludeFrom: - items: - type: string - type: array - matchAll: - type: boolean - replicateIn: - items: - type: string - type: array - required: - - matchAll - type: object - type: object - required: - - synchronization - - target - type: object - status: - description: ReplikaStatus defines the observed state of a Replika - properties: - conditions: - description: Conditions represent the latest available observations of an object's state - items: - description: "Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, \n type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }" - properties: - lastTransitionTime: - description: lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: message is a human readable message indicating details about the transition. This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. --- Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be useful (see .node.status.conditions), the ability to deconflict is important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - type: array - required: - - conditions - type: object - type: object - served: true - storage: true - subresources: - status: {} - diff --git a/deploy/deployment/replika-controller-manager.yaml b/deploy/deployment/replika-controller-manager.yaml deleted file mode 100644 index dd29b2e..0000000 --- a/deploy/deployment/replika-controller-manager.yaml +++ /dev/null @@ -1,106 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app.kubernetes.io/component: manager - app.kubernetes.io/created-by: replika - app.kubernetes.io/instance: controller-manager - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: replika - app.kubernetes.io/part-of: replika - control-plane: replika - name: replika-controller-manager - namespace: replika -spec: - replicas: 1 - selector: - matchLabels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: replika - control-plane: replika - template: - metadata: - annotations: - kubectl.kubernetes.io/default-container: manager - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: replika - control-plane: replika - spec: - affinity: - nodeAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - nodeSelectorTerms: - - matchExpressions: - - key: kubernetes.io/arch - operator: In - values: - - amd64 - - arm64 - - ppc64le - - s390x - - key: kubernetes.io/os - operator: In - values: - - linux - containers: - - args: - - --secure-listen-address=0.0.0.0:8443 - - --upstream=http://127.0.0.1:8080/ - - --logtostderr=true - - --v=0 - image: gcr.io/kubebuilder/kube-rbac-proxy:v0.13.1 - name: kube-rbac-proxy - ports: - - containerPort: 8443 - name: https - protocol: TCP - resources: - limits: - cpu: 500m - memory: 128Mi - requests: - cpu: 5m - memory: 64Mi - securityContext: - allowPrivilegeEscalation: false - capabilities: - drop: - - ALL - - args: - - --health-probe-bind-address=:8081 - - --metrics-bind-address=127.0.0.1:8080 - - --leader-elect - command: - - /manager - image: prosimcorp/replika:v0.3.0 - livenessProbe: - httpGet: - path: /healthz - port: 8081 - initialDelaySeconds: 15 - periodSeconds: 20 - name: manager - readinessProbe: - httpGet: - path: /readyz - port: 8081 - initialDelaySeconds: 5 - periodSeconds: 10 - resources: - limits: - cpu: 500m - memory: 128Mi - requests: - cpu: 10m - memory: 64Mi - securityContext: - allowPrivilegeEscalation: false - capabilities: - drop: - - ALL - securityContext: - runAsNonRoot: true - serviceAccountName: replika-controller-manager - terminationGracePeriodSeconds: 10 - diff --git a/deploy/kustomization.yaml b/deploy/kustomization.yaml deleted file mode 100644 index 2a6edd6..0000000 --- a/deploy/kustomization.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: -- clusterrole/replika-manager-role.yaml -- clusterrole/replika-metrics-reader.yaml -- clusterrole/replika-proxy-role.yaml -- clusterrolebinding/replika-manager-rolebinding.yaml -- clusterrolebinding/replika-proxy-rolebinding.yaml -- customresourcedefinition/replikas-replika-prosimcorp-com.yaml -- deployment/replika-controller-manager.yaml -- namespace/replika.yaml -- role/replika-leader-election-role.yaml -- rolebinding/replika-leader-election-rolebinding.yaml -- service/replika-controller-manager-metrics-service.yaml -- serviceaccount/replika-controller-manager.yaml diff --git a/deploy/namespace/replika.yaml b/deploy/namespace/replika.yaml deleted file mode 100644 index 6169d41..0000000 --- a/deploy/namespace/replika.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - labels: - app.kubernetes.io/component: manager - app.kubernetes.io/created-by: replika - app.kubernetes.io/instance: system - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: replika - app.kubernetes.io/part-of: replika - control-plane: replika - name: replika - diff --git a/deploy/role/replika-leader-election-role.yaml b/deploy/role/replika-leader-election-role.yaml deleted file mode 100644 index fd6ad81..0000000 --- a/deploy/role/replika-leader-election-role.yaml +++ /dev/null @@ -1,45 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - labels: - app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: replika - app.kubernetes.io/instance: leader-election-role - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: replika - app.kubernetes.io/part-of: replika - name: replika-leader-election-role - namespace: replika -rules: -- apiGroups: - - "" - resources: - - configmaps - verbs: - - get - - list - - watch - - create - - update - - patch - - delete -- apiGroups: - - coordination.k8s.io - resources: - - leases - verbs: - - get - - list - - watch - - create - - update - - patch - - delete -- apiGroups: - - "" - resources: - - events - verbs: - - create - - patch - diff --git a/deploy/rolebinding/replika-leader-election-rolebinding.yaml b/deploy/rolebinding/replika-leader-election-rolebinding.yaml deleted file mode 100644 index f72ceba..0000000 --- a/deploy/rolebinding/replika-leader-election-rolebinding.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - labels: - app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: replika - app.kubernetes.io/instance: leader-election-rolebinding - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: replika - app.kubernetes.io/part-of: replika - name: replika-leader-election-rolebinding - namespace: replika -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: replika-leader-election-role -subjects: -- kind: ServiceAccount - name: replika-controller-manager - namespace: replika - diff --git a/deploy/service/replika-controller-manager-metrics-service.yaml b/deploy/service/replika-controller-manager-metrics-service.yaml deleted file mode 100644 index adb4aee..0000000 --- a/deploy/service/replika-controller-manager-metrics-service.yaml +++ /dev/null @@ -1,24 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - labels: - app.kubernetes.io/component: kube-rbac-proxy - app.kubernetes.io/created-by: replika - app.kubernetes.io/instance: controller-manager-metrics-service - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: replika - app.kubernetes.io/part-of: replika - control-plane: replika - name: replika-controller-manager-metrics-service - namespace: replika -spec: - ports: - - name: https - port: 8443 - protocol: TCP - targetPort: https - selector: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: replika - control-plane: replika - diff --git a/deploy/serviceaccount/replika-controller-manager.yaml b/deploy/serviceaccount/replika-controller-manager.yaml deleted file mode 100644 index b96865e..0000000 --- a/deploy/serviceaccount/replika-controller-manager.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: v1 -kind: ServiceAccount -metadata: - labels: - app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: replika - app.kubernetes.io/instance: controller-manager - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: replika - app.kubernetes.io/part-of: replika - name: replika-controller-manager - namespace: replika -