You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2021/01/07 00:11:31 UTC

[skywalking-swck] branch master updated: Some features swctl needs (#19)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-swck.git


The following commit(s) were added to refs/heads/master by this push:
     new 8e7183a  Some features swctl needs (#19)
8e7183a is described below

commit 8e7183a65d6469de3083d9124a3502791283f8de
Author: Gao Hongtao <ha...@gmail.com>
AuthorDate: Thu Jan 7 08:11:21 2021 +0800

    Some features swctl needs (#19)
---
 CHANGES.md                                       |  2 ++
 pkg/kubernetes/kubernetes.go                     | 17 +++++++++++++----
 pkg/operator/manifests/ui/templates/ingress.yaml |  5 ++++-
 pkg/operator/repo/assets.gen.go                  |  9 ++++++---
 4 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 8787733..d9570ec 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -8,6 +8,8 @@ Release Notes.
 #### Features
 - Introduce custom metrics adapter to SkyWalking OAP cluster for Kubernetes HPA autoscaling.
 - Add RBAC files and service account to support Kubernetes coordination.
+- Add default and validation webhooks to operator controllers.
+- Add UI CRD to deploy skywalking UI server.
 
 #### Chores
 - Transform project layers to support multiple applications.
diff --git a/pkg/kubernetes/kubernetes.go b/pkg/kubernetes/kubernetes.go
index 5df8ff2..7e0b22c 100644
--- a/pkg/kubernetes/kubernetes.go
+++ b/pkg/kubernetes/kubernetes.go
@@ -54,6 +54,15 @@ func ApplyOverlay(current, overlay runtime.Object) error {
 
 // LoadTemplate loads a YAML file to a component
 func LoadTemplate(manifest string, values interface{}, funcMap template.FuncMap, spec interface{}) error {
+	bb, err := GenerateManifests(manifest, values, funcMap)
+	if err != nil {
+		return err
+	}
+	return yaml.Unmarshal(bb, spec)
+}
+
+// GenerateManifests generate manifests from templates, CR and values
+func GenerateManifests(manifest string, values interface{}, funcMap template.FuncMap) ([]byte, error) {
 	tmplBuilder := template.New("manifest").
 		Funcs(template.FuncMap{
 			"toYAML": toYAML,
@@ -64,18 +73,18 @@ func LoadTemplate(manifest string, values interface{}, funcMap template.FuncMap,
 	}
 	tmpl, err := tmplBuilder.Parse(manifest)
 	if err != nil {
-		return err
+		return nil, err
 	}
 	buf := bytes.Buffer{}
 	err = tmpl.Execute(&buf, values)
 	if err != nil {
-		return err
+		return nil, err
 	}
 	bb := stripCharacters(buf.Bytes())
 	if len(bb) < 1 {
-		return ErrNothingLoaded
+		return nil, ErrNothingLoaded
 	}
-	return yaml.Unmarshal(bb, spec)
+	return bb, nil
 }
 
 func toYAML(v interface{}) string {
diff --git a/pkg/operator/manifests/ui/templates/ingress.yaml b/pkg/operator/manifests/ui/templates/ingress.yaml
index fc24b38..017712c 100644
--- a/pkg/operator/manifests/ui/templates/ingress.yaml
+++ b/pkg/operator/manifests/ui/templates/ingress.yaml
@@ -40,8 +40,11 @@ spec:
         paths:
           - path: 
             backend:
-              serviceName: {{ .Name }}
+              serviceName: {{ .Name }}-ui
               servicePort: {{ $port.Port }}
+  {{- if $ingress.IngressClassName }}
+  ingressClassName: {{ $ingress.IngressClassName }}
+  {{end}}
   {{- if $ingress.TLS }}
   tls:
 {{ toYAML $ingress.TLS | indent 4 }}
diff --git a/pkg/operator/repo/assets.gen.go b/pkg/operator/repo/assets.gen.go
index 10bff8c..b198719 100644
--- a/pkg/operator/repo/assets.gen.go
+++ b/pkg/operator/repo/assets.gen.go
@@ -22,7 +22,7 @@
 // oapserver/templates/service.yaml (1.324kB)
 // oapserver/templates/service_account.yaml (1.09kB)
 // ui/templates/deployment.yaml (2.235kB)
-// ui/templates/ingress.yaml (1.655kB)
+// ui/templates/ingress.yaml (1.758kB)
 // ui/templates/service.yaml (1.112kB)
 
 package repo
@@ -499,8 +499,11 @@ spec:
         paths:
           - path: 
             backend:
-              serviceName: {{ .Name }}
+              serviceName: {{ .Name }}-ui
               servicePort: {{ $port.Port }}
+  {{- if $ingress.IngressClassName }}
+  ingressClassName: {{ $ingress.IngressClassName }}
+  {{end}}
   {{- if $ingress.TLS }}
   tls:
 {{ toYAML $ingress.TLS | indent 4 }}
@@ -519,7 +522,7 @@ func uiTemplatesIngressYaml() (*asset, error) {
 	}
 
 	info := bindataFileInfo{name: "ui/templates/ingress.yaml", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)}
-	a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x26, 0x9, 0x38, 0xb6, 0x6f, 0x54, 0x1f, 0xfd, 0xbe, 0xe4, 0xb9, 0x75, 0xe3, 0x19, 0x2a, 0x8, 0xd4, 0xf3, 0x1b, 0x4a, 0x5e, 0xba, 0x42, 0xb2, 0xc7, 0x5d, 0xf1, 0x8, 0x4d, 0x36, 0xb5, 0x78}}
+	a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xd9, 0x4d, 0xeb, 0xbb, 0xb8, 0x64, 0x23, 0x82, 0xfa, 0x80, 0xf3, 0xb, 0xb0, 0xf8, 0x4a, 0xaa, 0xf9, 0xef, 0xe0, 0x77, 0xcb, 0x53, 0x2f, 0x96, 0xf4, 0xba, 0x8f, 0x6b, 0xb6, 0xb8, 0x2, 0x85}}
 	return a, nil
 }