From 278038a38b60b43edbb51dd38b0bd497c1ea0376 Mon Sep 17 00:00:00 2001 From: dongming Date: Mon, 26 Dec 2022 17:22:39 +0800 Subject: [PATCH] l-24 run done --- config/samples/apps_v1_msbdeployment.yaml | 12 ------------ config/samples/apps_v1_msbdeployment_ingress.yaml | 11 +++++++++++ .../apps_v1_msbdeployment_ingress2nodeport.yaml | 11 +++++++++++ config/samples/apps_v1_msbdeployment_nodeport.yaml | 11 +++++++++++ .../apps_v1_msbdeployment_nodeport2ingress.yaml | 11 +++++++++++ controllers/generate-cr.go | 2 +- controllers/templates/deployment.yaml | 1 + controllers/templates/ingress.yaml | 1 + controllers/templates/service-np.yaml | 1 + controllers/templates/service.yaml | 1 + 10 files changed, 49 insertions(+), 13 deletions(-) delete mode 100644 config/samples/apps_v1_msbdeployment.yaml create mode 100644 config/samples/apps_v1_msbdeployment_ingress.yaml create mode 100644 config/samples/apps_v1_msbdeployment_ingress2nodeport.yaml create mode 100644 config/samples/apps_v1_msbdeployment_nodeport.yaml create mode 100644 config/samples/apps_v1_msbdeployment_nodeport2ingress.yaml diff --git a/config/samples/apps_v1_msbdeployment.yaml b/config/samples/apps_v1_msbdeployment.yaml deleted file mode 100644 index 19da15d..0000000 --- a/config/samples/apps_v1_msbdeployment.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: apps.mashibing.com/v1 -kind: MsbDeployment -metadata: - labels: - app.kubernetes.io/name: msbdeployment - app.kubernetes.io/instance: msbdeployment-sample - app.kubernetes.io/part-of: mashibing-deployment - app.kuberentes.io/managed-by: kustomize - app.kubernetes.io/created-by: mashibing-deployment - name: msbdeployment-sample -spec: - # TODO(user): Add fields here diff --git a/config/samples/apps_v1_msbdeployment_ingress.yaml b/config/samples/apps_v1_msbdeployment_ingress.yaml new file mode 100644 index 0000000..2e57894 --- /dev/null +++ b/config/samples/apps_v1_msbdeployment_ingress.yaml @@ -0,0 +1,11 @@ +apiVersion: apps.mashibing.com/v1 +kind: MsbDeployment +metadata: + name: msbdeployment-ingress +spec: + image: nginx + port: 80 + replicas: 2 + expose: + mode: ingress + ingressDomain: www.mashingbing-test.com diff --git a/config/samples/apps_v1_msbdeployment_ingress2nodeport.yaml b/config/samples/apps_v1_msbdeployment_ingress2nodeport.yaml new file mode 100644 index 0000000..53cd745 --- /dev/null +++ b/config/samples/apps_v1_msbdeployment_ingress2nodeport.yaml @@ -0,0 +1,11 @@ +apiVersion: apps.mashibing.com/v1 +kind: MsbDeployment +metadata: + name: msbdeployment-ingress +spec: + image: nginx + port: 80 + replicas: 2 + expose: + mode: nodeport + nodePort: 30000 diff --git a/config/samples/apps_v1_msbdeployment_nodeport.yaml b/config/samples/apps_v1_msbdeployment_nodeport.yaml new file mode 100644 index 0000000..06963aa --- /dev/null +++ b/config/samples/apps_v1_msbdeployment_nodeport.yaml @@ -0,0 +1,11 @@ +apiVersion: apps.mashibing.com/v1 +kind: MsbDeployment +metadata: + name: msbdeployment-nodeport +spec: + image: nginx + port: 80 + replicas: 2 + expose: + mode: nodeport + nodePort: 30000 diff --git a/config/samples/apps_v1_msbdeployment_nodeport2ingress.yaml b/config/samples/apps_v1_msbdeployment_nodeport2ingress.yaml new file mode 100644 index 0000000..dd87969 --- /dev/null +++ b/config/samples/apps_v1_msbdeployment_nodeport2ingress.yaml @@ -0,0 +1,11 @@ +apiVersion: apps.mashibing.com/v1 +kind: MsbDeployment +metadata: + name: msbdeployment-nodeport +spec: + image: nginx + port: 80 + replicas: 2 + expose: + mode: ingress + ingressDomain: www.mashingbing-test.com diff --git a/controllers/generate-cr.go b/controllers/generate-cr.go index ea988d4..8ad4725 100644 --- a/controllers/generate-cr.go +++ b/controllers/generate-cr.go @@ -14,7 +14,7 @@ import ( ) func parseTemplate(md *myAppsv1.MsbDeployment, templateName string) ([]byte, error) { - tmpl, err := template.ParseFiles(fmt.Sprintf("templates/%s", templateName)) + tmpl, err := template.ParseFiles(fmt.Sprintf("controllers/templates/%s", templateName)) if err != nil { return nil, err } diff --git a/controllers/templates/deployment.yaml b/controllers/templates/deployment.yaml index ed975a1..3a45c31 100644 --- a/controllers/templates/deployment.yaml +++ b/controllers/templates/deployment.yaml @@ -2,6 +2,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: {{ .ObjectMeta.Name }} + namespace: {{ .ObjectMeta.Namespace }} labels: app: {{ .ObjectMeta.Name }} spec: diff --git a/controllers/templates/ingress.yaml b/controllers/templates/ingress.yaml index 6324f4e..e68551c 100644 --- a/controllers/templates/ingress.yaml +++ b/controllers/templates/ingress.yaml @@ -2,6 +2,7 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: {{ .ObjectMeta.Name }} + namespace: {{ .ObjectMeta.Namespace }} spec: ingressClassName: nginx rules: diff --git a/controllers/templates/service-np.yaml b/controllers/templates/service-np.yaml index 5a6e23e..44b7e6d 100644 --- a/controllers/templates/service-np.yaml +++ b/controllers/templates/service-np.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: Service metadata: name: {{ .ObjectMeta.Name }} + namespace: {{ .ObjectMeta.Namespace }} spec: type: NodePort selector: diff --git a/controllers/templates/service.yaml b/controllers/templates/service.yaml index 1252f28..0456cdc 100644 --- a/controllers/templates/service.yaml +++ b/controllers/templates/service.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: Service metadata: name: {{ .ObjectMeta.Name }} + namespace: {{ .ObjectMeta.Namespace }} spec: selector: app: {{ .ObjectMeta.Name }}