Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update deployment resources #4

Merged
merged 2 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Generated by Fabric8 CRDGenerator, manual edits might get overwritten!
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: microfrontends.io.github.onecx.product.store
spec:
group: io.github.onecx.product.store
names:
kind: Microfrontend
plural: microfrontends
singular: microfrontend
scope: Namespaced
versions:
- name: v1
schema:
openAPIV3Schema:
properties:
spec:
properties:
display-name:
type: string
app-id:
type: string
product-name:
type: string
remote-entry:
type: string
wc-tag-name:
type: string
remote-name:
type: string
exposed-module:
type: string
mfe-id:
type: string
note:
type: string
base-path:
type: string
app-version:
type: string
remote-base-url:
type: string
module-type:
enum:
- WEBCOMPONENT
- ANGULAR
type: string
contact:
type: string
type: object
status:
properties:
response-code:
type: integer
status:
enum:
- UPDATED
- ERROR
- CREATED
- UNDEFINED
type: string
product-name:
type: string
mfe-id:
type: string
message:
type: string
observedGeneration:
type: integer
type: object
type: object
served: true
storage: true
subresources:
status: {}
12 changes: 12 additions & 0 deletions src/main/helm/templates/operator-cluster-role-binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ .Release.Name }}-{{ .Values.app.name }}-validating-role-binding
roleRef:
kind: ClusterRole
apiGroup: rbac.authorization.k8s.io
name: {{ .Release.Name }}-{{ .Values.app.name }}-validating-cluster-role
subjects:
- kind: ServiceAccount
name: {{ .Release.Name }}-{{ .Values.app.name }}
namespace: {{ .Release.Namespace }}
12 changes: 12 additions & 0 deletions src/main/helm/templates/operator-cluster-role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ .Release.Name }}-{{ .Values.app.name }}-validating-cluster-role
rules:
- apiGroups:
- apiextensions.k8s.io
resources:
- customresourcedefinitions
verbs:
- get
- list
43 changes: 43 additions & 0 deletions src/main/helm/templates/product-cluster-role-binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{ if eq $.Values.watchNamespaces "JOSDK_WATCH_CURRENT" }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ .Release.Name }}-{{ .Values.app.name }}-role-binding
roleRef:
kind: ClusterRole
apiGroup: rbac.authorization.k8s.io
name: {{ .Release.Name }}-{{ .Values.app.name }}-cluster-role
subjects:
- kind: ServiceAccount
name: {{ .Release.Name }}-{{ .Values.app.name }}
{{ else if eq $.Values.watchNamespaces "JOSDK_ALL_NAMESPACES" }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ .Release.Name }}-{{ .Values.app.name }}-role-binding
roleRef:
kind: ClusterRole
apiGroup: rbac.authorization.k8s.io
name: {{ .Release.Name }}-{{ .Values.app.name }}-cluster-role
subjects:
- kind: ServiceAccount
name: {{ .Release.Name }}-{{ .Values.app.name }}
namespace: {{ $.Release.Namespace }}
{{ else }}
{{ range $anamespace := ( split "," $.Values.watchNamespaces ) }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ .Release.Name }}-{{ .Values.app.name }}-role-binding
namespace: {{ $anamespace }}
roleRef:
kind: ClusterRole
apiGroup: rbac.authorization.k8s.io
name: {{ .Release.Name }}-{{ .Values.app.name }}-cluster-role
subjects:
- kind: ServiceAccount
name: {{ .Release.Name }}-{{ .Values.app.name }}
namespace: {{ $.Release.Namespace }}
---
{{- end }}
{{- end }}
19 changes: 19 additions & 0 deletions src/main/helm/templates/product-cluster-role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ .Release.Name }}-{{ .Values.app.name }}-cluster-role
rules:
- apiGroups:
- io.github.onecx.product.store
resources:
- "microfrontends"
- "microfrontends/status"
- "microfrontends/finalizers"
verbs:
- get
- list
- watch
- patch
- update
- create
- delete
4 changes: 4 additions & 0 deletions src/main/helm/templates/service-account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Release.Name }}-{{ .Values.app.name }}
15 changes: 14 additions & 1 deletion src/main/helm/values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
app:
name: mfe-operator
image:
repository: "onecx/onecx-product-store-mfe-operator"
tag: 999-SNAPSHOT
env:
# See watchNamespaces
"QUARKUS_OPERATOR_SDK_CONTROLLERS_PRODUCT_NAMESPACES": "JOSDK_WATCH_CURRENT"
envCustom:
- name: KUBERNETES_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
serviceAccount:
enabled: true

# Values: JOSDK_WATCH_CURRENT, JOSDK_ALL_NAMESPACES or comma separated list of namespaces
watchNamespaces: "JOSDK_WATCH_CURRENT"
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
import io.fabric8.kubernetes.model.annotation.Version;

@Version("v1")
@Group("io.github.onecx.product.store.mfe")
@Group("io.github.onecx.product.store")
public class Microfrontend extends CustomResource<MicrofrontendSpec, MicrofrontendStatus> implements Namespaced {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.github.onecx.product.store.mfe.operator;

import static io.javaoperatorsdk.operator.api.reconciler.Constants.WATCH_CURRENT_NAMESPACE;

import jakarta.inject.Inject;
import jakarta.ws.rs.WebApplicationException;

Expand All @@ -11,10 +13,10 @@
import io.javaoperatorsdk.operator.processing.event.source.filter.OnAddFilter;
import io.javaoperatorsdk.operator.processing.event.source.filter.OnUpdateFilter;

@ControllerConfiguration(onAddFilter = ProductMicrofrontendReconciler.MicrofrontendAddFilter.class, onUpdateFilter = ProductMicrofrontendReconciler.MicrofrontendUpdateFilter.class)
public class ProductMicrofrontendReconciler implements Reconciler<Microfrontend>, ErrorStatusHandler<Microfrontend> {
@ControllerConfiguration(name = "microfrontend", namespaces = WATCH_CURRENT_NAMESPACE, onAddFilter = MicrofrontendController.MicrofrontendAddFilter.class, onUpdateFilter = MicrofrontendController.MicrofrontendUpdateFilter.class)
public class MicrofrontendController implements Reconciler<Microfrontend>, ErrorStatusHandler<Microfrontend> {

private static final Logger log = LoggerFactory.getLogger(ProductMicrofrontendReconciler.class);
private static final Logger log = LoggerFactory.getLogger(MicrofrontendController.class);

@Inject
ProductStoreService service;
Expand Down
46 changes: 21 additions & 25 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@

# BUILD
quarkus.openapi-generator.codegen.input-base-dir=target/tmp/openapi
quarkus.openapi-generator.codegen.spec.onecx_product_store_operator_mfe_v1_yaml.config-key=product_store_client
quarkus.openapi-generator.codegen.spec.onecx_product_store_operator_mfe_v1_yaml.base-package=gen.io.github.onecx.product.store.mfe.v1
quarkus.openapi-generator.codegen.spec.onecx_product_store_operator_mfe_v1_yaml.return-response=true


# CONFIG

quarkus.kubernetes-client.devservices.override-kubeconfig=true

# validate product store name, relevant only for multi-store
onecx.product.store.mfe.operator.multi-enabled=false
onecx.product.store.mfe.operator.name=onecx


# TEST
%test.quarkus.mockserver.devservices.config-class-path=true
%test.quarkus.mockserver.devservices.config-file=/mockserver.properties
%test.quarkus.mockserver.devservices.config-dir=/mockserver
%test.quarkus.mockserver.devservices.log=false
%test.quarkus.mockserver.devservices.reuse=true
%test.quarkus.rest-client.product_store_client.url=${quarkus.mockserver.endpoint}


# PROD
%prod.quarkus.rest-client.product_store_client.url=http://product-store-svc:8080

# BUILD
quarkus.openapi-generator.codegen.input-base-dir=target/tmp/openapi
quarkus.openapi-generator.codegen.spec.onecx_product_store_operator_mfe_v1_yaml.config-key=product_store_client
quarkus.openapi-generator.codegen.spec.onecx_product_store_operator_mfe_v1_yaml.base-package=gen.io.github.onecx.product.store.mfe.v1
quarkus.openapi-generator.codegen.spec.onecx_product_store_operator_mfe_v1_yaml.return-response=true

# CONFIG
quarkus.kubernetes-client.devservices.override-kubeconfig=true

# TEST
%test.quarkus.mockserver.devservices.config-class-path=true
%test.quarkus.mockserver.devservices.config-file=/mockserver.properties
%test.quarkus.mockserver.devservices.config-dir=/mockserver
%test.quarkus.mockserver.devservices.log=false
%test.quarkus.mockserver.devservices.reuse=true
%test.quarkus.rest-client.product_store_client.url=${quarkus.mockserver.endpoint}

Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
import io.quarkus.test.junit.QuarkusTest;

@QuarkusTest
class ProductMicrofrontendReconcilerResponseTest extends AbstractTest {
class MicrofrontendControllerResponseTest extends AbstractTest {

@InjectMock
ProductStoreService productStoreService;

@Inject
ProductMicrofrontendReconciler reconciler;
MicrofrontendController reconciler;

@BeforeEach
void beforeAll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
import io.quarkus.test.junit.QuarkusTest;

@QuarkusTest
class ProductMicrofrontendReconcilerTest extends AbstractTest {
class MicrofrontendControllerTest extends AbstractTest {

final static Logger log = LoggerFactory.getLogger(ProductMicrofrontendReconcilerTest.class);
final static Logger log = LoggerFactory.getLogger(MicrofrontendControllerTest.class);

@Inject
Operator operator;
Expand Down
Loading