Add obsevability addon (#2091)

* Support Obsevability

- Support displaying and filter logs
- Support metrics and traces

* register datasource

* install prometheus

* install prometheus and register datasource

* Also install and register Prometheus

* remove unneeded file

* register datasource with clusterip

* register prometheus

* Support importing Grafana Dashboard

Added a trait to import Grafana Dashboard on component Grafana

* tmp

* 1. make observability as addon
2. make it more esay to gen addon

* use [[]] as gen addon delim

* url->urls

* add 2 url

* fix template

* fix args

* remove doc

* move url,fix test

* last modify!

* change arg name to grafana-domain

Co-authored-by: zzxwill <zzxwill@gmail.com>
This commit is contained in:
qiaozp
2021-08-17 14:46:07 +08:00
committed by GitHub
co-authored by zzxwill
parent a599a6a88b
commit 050afca7a6
23 changed files with 844 additions and 28 deletions
@@ -5933,7 +5933,8 @@ data:
== \"helm\" {\n\t\t\t\t\t\tkind: \"HelmRepository\"\n\t\t\t\t\t}\n\t\t\t\t\tname:
\ context.name\n\t\t\t\t\tnamespace: context.namespace\n\t\t\t\t}\n\t\t\t\tinterval:
parameter.pullInterval\n\t\t\t}\n\t\t}\n\t\tif parameter.targetNamespace
!= _|_ {\n\t\t\ttargetNamespace: parameter.targetNamespace\n\t\t}\n\t\tif
!= _|_ {\n\t\t\ttargetNamespace: parameter.targetNamespace\n\t\t}\n
\ if parameter.releaseName != _|_ {\n\t\t\treleaseName: parameter.releaseName\n\t\t}\n\n\t\tif
parameter.values != _|_ {\n\t\t\tvalues: parameter.values\n\t\t}\n\t}\n}\n\nparameter:
{\n\trepoType: \"git\" | \"helm\"\n\t// +usage=The Git or Helm repository
URL, accept HTTP/S or SSH address as git url.\n\trepoUrl: string\n\t//
@@ -5946,7 +5947,8 @@ data:
name of the secret containing authentication credentials for the
Helm repository.\n\tsecretRef?: string\n\t// +usage=The namespace
for helm chart\n\ttargetNamespace?: string\n\t// +usage=Chart version\n\tvalue?:
#nestedmap\n}\n\n#nestedmap: {\n\t...\n} \n"
#nestedmap\n // +usage=The release name\n releaseName?: string\n}\n\n#nestedmap:
{\n\t...\n} \n"
workload:
type: autodetects.core.oam.dev
type: raw
@@ -0,0 +1,127 @@
apiVersion: v1
data:
initializer: |
apiVersion: core.oam.dev/v1beta1
kind: Initializer
metadata:
annotations:
addons.oam.dev/description: Preparations that observability need
name: observability-asset
namespace: vela-system
spec:
appTemplate:
spec:
components:
- name: observability
properties:
apiVersion: v1
kind: Namespace
metadata:
name: observability
type: raw
- name: import-grafana-dashboard
properties:
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
annotations:
definition.oam.dev/description: Add a datasource to Grafana
name: import-grafana-dashboard
namespace: vela-system
spec:
schematic:
cue:
template: "outputs: registerdatasource: {\n\tapiVersion: \"grafana.extension.oam.dev/v1alpha1\"\n\tkind:
\ \"ImportDashboard\"\n\tspec: {\n\t\tgrafana: {\n\t\t\tservice:
\ parameter.grafanaServiceName\n\t\t\tnamespace:
\ parameter.grafanaServiceNamespace\n\t\t\tcredentialSecret:
\ parameter.credentialSecret\n\t\t\tcredentialSecretNamespace:
parameter.credentialSecretNamespace\n\t\t}\n\t\turls: parameter.urls\n\t}\n}\nparameter:
{\n\tgrafanaServiceName: string\n\tgrafanaServiceNamespace:
\ *\"default\" | string\n\tcredentialSecret: string\n\tcredentialSecretNamespace:
*\"default\" | string\n\turls: [...string]\n} \n"
type: raw
- name: pure-ingress
properties:
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
annotations:
definition.oam.dev/description: Enable public web traffic for the component
without creating a Service.
name: pure-ingress
namespace: vela-system
spec:
schematic:
cue:
template: "\noutputs: ingress: {\n\tapiVersion: \"networking.k8s.io/v1beta1\"\n\tkind:
\ \"Ingress\"\n\tmetadata:\n\t\tname: context.name\n\tspec:
{\n\t\trules: [{\n\t\t\thost: parameter.domain\n\t\t\thttp: {\n\t\t\t\tpaths:
[\n\t\t\t\t\tfor k, v in parameter.http {\n\t\t\t\t\t\tpath: k\n\t\t\t\t\t\tbackend:
{\n\t\t\t\t\t\t\tserviceName: context.name\n\t\t\t\t\t\t\tservicePort:
v\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t}\n\t\t}]\n\t}\n}\n\nparameter:
{\n\t// +usage=Specify the domain you want to expose\n\tdomain:
string\n\n\t// +usage=Specify the mapping relationship between the
http path and the workload port\n\thttp: [string]: int\n}\n"
status:
customStatus: |-
let igs = context.outputs.ingress.status.loadBalancer.ingress
if igs == _|_ {
message: "No loadBalancer found, visiting by using 'vela port-forward " + context.appName + " --route'\n"
}
if len(igs) > 0 {
if igs[0].ip != _|_ {
message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host + ", IP: " + igs[0].ip
}
if igs[0].ip == _|_ {
message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host
}
}
healthPolicy: |
isHealth: len(context.outputs.ingress.status.loadBalancer.ingress) > 0
type: raw
- name: register-grafana-datasource
properties:
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
annotations:
definition.oam.dev/description: Add a datasource to Grafana
name: register-grafana-datasource
namespace: vela-system
spec:
schematic:
cue:
template: "outputs: registerdatasource: {\n\tapiVersion: \"grafana.extension.oam.dev/v1alpha1\"\n\tkind:
\ \"DatasourceRegistration\"\n\tspec: {\n\t\tgrafana: {\n\t\t\tservice:
\ parameter.grafanaServiceName\n\t\t\tnamespace:
\ parameter.grafanaServiceNamespace\n\t\t\tcredentialSecret:
\ parameter.credentialSecret\n\t\t\tcredentialSecretNamespace:
parameter.credentialSecretNamespace\n\t\t}\n\t\tdatasource: {\n\t\t\tname:
\ parameter.name\n\t\t\ttype: parameter.type\n\t\t\taccess:
\ parameter.access\n\t\t\tservice: parameter.service\n\t\t\tnamespace:
parameter.namespace\n\t\t}\n\t}\n}\n\nparameter: {\n\tgrafanaServiceName:
\ string\n\tgrafanaServiceNamespace: *\"default\" | string\n\tcredentialSecret:
\ string\n\tcredentialSecretNamespace: string\n\tname: string\n\ttype:
\ string\n\taccess: *\"proxy\"
| string\n\tservice: string\n\tnamespace: *\"default\"
| string\n}\n"
type: raw
status:
rollout:
batchRollingState: ""
currentBatch: 0
lastTargetAppRevision: ""
rollingState: ""
upgradedReadyReplicas: 0
upgradedReplicas: 0
status:
observedGeneration: 0
kind: ConfigMap
metadata:
annotations:
addons.oam.dev/description: Preparations that observability need
labels:
addons.oam.dev/type: observability-asset
name: observability-asset
namespace: {{.Values.systemDefinitionNamespace}}
@@ -0,0 +1,139 @@
apiVersion: v1
data:
initializer: |
apiVersion: core.oam.dev/v1beta1
kind: Initializer
metadata:
annotations:
addons.oam.dev/description: An out of the box solution for KubeVela observability
name: observability
namespace: observability
spec:
appTemplate:
spec:
components:
- name: grafana-registration
properties:
branch: master
chart: ./chart
repoType: git
repoUrl: https://github.com/oam-dev/grafana-registration
targetNamespace: observability
values:
replicaCount: 1
type: helm
- name: grafana
properties:
chart: grafana
releaseName: grafana
repoType: helm
repoUrl: https://grafana.github.io/helm-charts
targetNamespace: observability
version: 6.14.1
traits:
- properties:
domain: '[[ index .Args "grafana-domain" ]]'
http:
/: 80
type: pure-ingress
- properties:
credentialSecret: grafana
credentialSecretNamespace: observability
grafanaServiceName: grafana
grafanaServiceNamespace: observability
urls:
- https://raw.githubusercontent.com/oam-dev/grafana-registration/master/dashboards/kubevela_core_logging.json
- https://raw.githubusercontent.com/oam-dev/grafana-registration/master/dashboards/kubevela_core_monitoring.json
type: import-grafana-dashboard
type: helm
- name: loki
properties:
chart: loki-stack
releaseName: loki
repoType: helm
repoUrl: https://grafana.github.io/helm-charts
targetNamespace: observability
version: 2.4.1
traits:
- properties:
access: proxy
credentialSecret: grafana
credentialSecretNamespace: observability
grafanaServiceName: grafana
grafanaServiceNamespace: observability
name: loki
namespace: observability
service: loki
type: loki
type: register-grafana-datasource
type: helm
- name: prometheus-server
properties:
chart: prometheus
releaseName: prometheus
repoType: helm
repoUrl: https://prometheus-community.github.io/helm-charts
targetNamespace: observability
values:
alertmanager:
persistentVolume:
enabled: '[[ index .Args "alertmanager-pvc-enabled" | default "true"
]]'
size: '[[ index .Args "alertmanager-pvc-size" | default "20Gi" ]]'
storageClass: '[[ index .Args "alertmanager-pvc-class" ]]'
server:
persistentVolume:
enabled: '[[ index .Args "server-pvc-enabled" | default "true" ]]'
size: '[[ index .Args "server-pvc-size" | default "20Gi" ]]'
storageClass: '[[ index .Args "server-pvc-class" ]]'
version: 14.4.1
traits:
- properties:
access: proxy
credentialSecret: grafana
credentialSecretNamespace: observability
grafanaServiceName: grafana
grafanaServiceNamespace: observability
name: prometheus
namespace: observability
service: prometheus-server
type: prometheus
type: register-grafana-datasource
type: helm
- name: kube-state-metrics
properties:
chart: kube-state-metrics
repoType: helm
repoUrl: https://prometheus-community.github.io/helm-charts
targetNamespace: observability
version: 3.4.1
type: helm
status:
rollout:
batchRollingState: ""
currentBatch: 0
lastTargetAppRevision: ""
rollingState: ""
upgradedReadyReplicas: 0
upgradedReplicas: 0
dependsOn:
- ref:
apiVersion: core.oam.dev/v1beta1
kind: Initializer
name: fluxcd
namespace: vela-system
- ref:
apiVersion: core.oam.dev/v1beta1
kind: Initializer
name: observability-asset
namespace: vela-system
status:
observedGeneration: 0
kind: ConfigMap
metadata:
annotations:
addons.oam.dev/description: An out of the box solution for KubeVela observability
labels:
addons.oam.dev/type: observability
name: observability
namespace: {{.Values.systemDefinitionNamespace}}
+4 -4
View File
@@ -57,7 +57,7 @@ var _ = Describe("Addon Test", func() {
})
})
Context("Enable addon", func() {
It("Enable addon fluxcd", func() {
It("Enable addon test-addon", func() {
output, err := e2e.Exec("vela addon enable test-addon")
Expect(err).NotTo(HaveOccurred())
Expect(output).To(ContainSubstring("Successfully enable addon"))
@@ -80,7 +80,7 @@ var _ = Describe("Addon Test", func() {
})
Context("Disable addon", func() {
It("Disable addon fluxcd", func() {
It("Disable addon test-addon", func() {
output, err := e2e.LongTimeExec("vela addon disable test-input-addon", 600*time.Second)
Expect(err).NotTo(HaveOccurred())
Expect(output).To(ContainSubstring("Successfully disable addon"))
@@ -162,9 +162,9 @@ data:
components:
- name: test-chart
properties:
chart: {{ index .Args "chart" }}
chart: [[ index .Args "chart" ]]
repoType: helm
repoUrl: {{ index .Args "repoUrl" }}
repoUrl: [[ index .Args "repoUrl" ]]
type: helm
status:
rollout:
+2 -1
View File
@@ -24,6 +24,7 @@ import (
"text/template"
"time"
"github.com/Masterminds/sprig"
"github.com/gosuri/uitable"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@@ -306,7 +307,7 @@ func (a *Addon) renderInitializer() (*unstructured.Unstructured, error) {
if a.Args == nil {
a.Args = map[string]string{}
}
t, err := template.New("addon-template").Parse(a.initYaml)
t, err := template.New("addon-template").Delims("[[", "]]").Funcs(sprig.TxtFuncMap()).Parse(a.initYaml)
if err != nil {
return nil, errors.Wrap(err, "parsing addon initializer template error")
}
+4 -2
View File
@@ -5930,7 +5930,8 @@ spec:
== \"helm\" {\n\t\t\t\t\t\tkind: \"HelmRepository\"\n\t\t\t\t\t}\n\t\t\t\t\tname:
\ context.name\n\t\t\t\t\tnamespace: context.namespace\n\t\t\t\t}\n\t\t\t\tinterval:
parameter.pullInterval\n\t\t\t}\n\t\t}\n\t\tif parameter.targetNamespace
!= _|_ {\n\t\t\ttargetNamespace: parameter.targetNamespace\n\t\t}\n\t\tif
!= _|_ {\n\t\t\ttargetNamespace: parameter.targetNamespace\n\t\t}\n
\ if parameter.releaseName != _|_ {\n\t\t\treleaseName: parameter.releaseName\n\t\t}\n\n\t\tif
parameter.values != _|_ {\n\t\t\tvalues: parameter.values\n\t\t}\n\t}\n}\n\nparameter:
{\n\trepoType: \"git\" | \"helm\"\n\t// +usage=The Git or Helm repository
URL, accept HTTP/S or SSH address as git url.\n\trepoUrl: string\n\t//
@@ -5943,7 +5944,8 @@ spec:
name of the secret containing authentication credentials for the
Helm repository.\n\tsecretRef?: string\n\t// +usage=The namespace
for helm chart\n\ttargetNamespace?: string\n\t// +usage=Chart version\n\tvalue?:
#nestedmap\n}\n\n#nestedmap: {\n\t...\n} \n"
#nestedmap\n // +usage=The release name\n releaseName?: string\n}\n\n#nestedmap:
{\n\t...\n} \n"
workload:
type: autodetects.core.oam.dev
type: raw
@@ -0,0 +1,116 @@
apiVersion: core.oam.dev/v1beta1
kind: Initializer
metadata:
annotations:
addons.oam.dev/description: Preparations that observability need
name: observability-asset
namespace: vela-system
spec:
appTemplate:
spec:
components:
- name: observability
properties:
apiVersion: v1
kind: Namespace
metadata:
name: observability
type: raw
- name: import-grafana-dashboard
properties:
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
annotations:
definition.oam.dev/description: Add a datasource to Grafana
name: import-grafana-dashboard
namespace: vela-system
spec:
schematic:
cue:
template: "outputs: registerdatasource: {\n\tapiVersion: \"grafana.extension.oam.dev/v1alpha1\"\n\tkind:
\ \"ImportDashboard\"\n\tspec: {\n\t\tgrafana: {\n\t\t\tservice:
\ parameter.grafanaServiceName\n\t\t\tnamespace:
\ parameter.grafanaServiceNamespace\n\t\t\tcredentialSecret:
\ parameter.credentialSecret\n\t\t\tcredentialSecretNamespace:
parameter.credentialSecretNamespace\n\t\t}\n\t\turls: parameter.urls\n\t}\n}\nparameter:
{\n\tgrafanaServiceName: string\n\tgrafanaServiceNamespace:
\ *\"default\" | string\n\tcredentialSecret: string\n\tcredentialSecretNamespace:
*\"default\" | string\n\turls: [...string]\n} \n"
type: raw
- name: pure-ingress
properties:
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
annotations:
definition.oam.dev/description: Enable public web traffic for the component
without creating a Service.
name: pure-ingress
namespace: vela-system
spec:
schematic:
cue:
template: "\noutputs: ingress: {\n\tapiVersion: \"networking.k8s.io/v1beta1\"\n\tkind:
\ \"Ingress\"\n\tmetadata:\n\t\tname: context.name\n\tspec:
{\n\t\trules: [{\n\t\t\thost: parameter.domain\n\t\t\thttp: {\n\t\t\t\tpaths:
[\n\t\t\t\t\tfor k, v in parameter.http {\n\t\t\t\t\t\tpath: k\n\t\t\t\t\t\tbackend:
{\n\t\t\t\t\t\t\tserviceName: context.name\n\t\t\t\t\t\t\tservicePort:
v\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t}\n\t\t}]\n\t}\n}\n\nparameter:
{\n\t// +usage=Specify the domain you want to expose\n\tdomain:
string\n\n\t// +usage=Specify the mapping relationship between the
http path and the workload port\n\thttp: [string]: int\n}\n"
status:
customStatus: |-
let igs = context.outputs.ingress.status.loadBalancer.ingress
if igs == _|_ {
message: "No loadBalancer found, visiting by using 'vela port-forward " + context.appName + " --route'\n"
}
if len(igs) > 0 {
if igs[0].ip != _|_ {
message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host + ", IP: " + igs[0].ip
}
if igs[0].ip == _|_ {
message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host
}
}
healthPolicy: |
isHealth: len(context.outputs.ingress.status.loadBalancer.ingress) > 0
type: raw
- name: register-grafana-datasource
properties:
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
annotations:
definition.oam.dev/description: Add a datasource to Grafana
name: register-grafana-datasource
namespace: vela-system
spec:
schematic:
cue:
template: "outputs: registerdatasource: {\n\tapiVersion: \"grafana.extension.oam.dev/v1alpha1\"\n\tkind:
\ \"DatasourceRegistration\"\n\tspec: {\n\t\tgrafana: {\n\t\t\tservice:
\ parameter.grafanaServiceName\n\t\t\tnamespace:
\ parameter.grafanaServiceNamespace\n\t\t\tcredentialSecret:
\ parameter.credentialSecret\n\t\t\tcredentialSecretNamespace:
parameter.credentialSecretNamespace\n\t\t}\n\t\tdatasource: {\n\t\t\tname:
\ parameter.name\n\t\t\ttype: parameter.type\n\t\t\taccess:
\ parameter.access\n\t\t\tservice: parameter.service\n\t\t\tnamespace:
parameter.namespace\n\t\t}\n\t}\n}\n\nparameter: {\n\tgrafanaServiceName:
\ string\n\tgrafanaServiceNamespace: *\"default\" | string\n\tcredentialSecret:
\ string\n\tcredentialSecretNamespace: string\n\tname: string\n\ttype:
\ string\n\taccess: *\"proxy\"
| string\n\tservice: string\n\tnamespace: *\"default\"
| string\n}\n"
type: raw
status:
rollout:
batchRollingState: ""
currentBatch: 0
lastTargetAppRevision: ""
rollingState: ""
upgradedReadyReplicas: 0
upgradedReplicas: 0
status:
observedGeneration: 0
@@ -0,0 +1,128 @@
apiVersion: core.oam.dev/v1beta1
kind: Initializer
metadata:
annotations:
addons.oam.dev/description: An out of the box solution for KubeVela observability
name: observability
namespace: observability
spec:
appTemplate:
spec:
components:
- name: grafana-registration
properties:
branch: master
chart: ./chart
repoType: git
repoUrl: https://github.com/oam-dev/grafana-registration
targetNamespace: observability
values:
replicaCount: 1
type: helm
- name: grafana
properties:
chart: grafana
releaseName: grafana
repoType: helm
repoUrl: https://grafana.github.io/helm-charts
targetNamespace: observability
version: 6.14.1
traits:
- properties:
domain: '[[ index .Args "grafana-domain" ]]'
http:
/: 80
type: pure-ingress
- properties:
credentialSecret: grafana
credentialSecretNamespace: observability
grafanaServiceName: grafana
grafanaServiceNamespace: observability
urls:
- https://raw.githubusercontent.com/oam-dev/grafana-registration/master/dashboards/kubevela_core_logging.json
- https://raw.githubusercontent.com/oam-dev/grafana-registration/master/dashboards/kubevela_core_monitoring.json
type: import-grafana-dashboard
type: helm
- name: loki
properties:
chart: loki-stack
releaseName: loki
repoType: helm
repoUrl: https://grafana.github.io/helm-charts
targetNamespace: observability
version: 2.4.1
traits:
- properties:
access: proxy
credentialSecret: grafana
credentialSecretNamespace: observability
grafanaServiceName: grafana
grafanaServiceNamespace: observability
name: loki
namespace: observability
service: loki
type: loki
type: register-grafana-datasource
type: helm
- name: prometheus-server
properties:
chart: prometheus
releaseName: prometheus
repoType: helm
repoUrl: https://prometheus-community.github.io/helm-charts
targetNamespace: observability
values:
alertmanager:
persistentVolume:
enabled: '[[ index .Args "alertmanager-pvc-enabled" | default "true"
]]'
size: '[[ index .Args "alertmanager-pvc-size" | default "20Gi" ]]'
storageClass: '[[ index .Args "alertmanager-pvc-class" ]]'
server:
persistentVolume:
enabled: '[[ index .Args "server-pvc-enabled" | default "true" ]]'
size: '[[ index .Args "server-pvc-size" | default "20Gi" ]]'
storageClass: '[[ index .Args "server-pvc-class" ]]'
version: 14.4.1
traits:
- properties:
access: proxy
credentialSecret: grafana
credentialSecretNamespace: observability
grafanaServiceName: grafana
grafanaServiceNamespace: observability
name: prometheus
namespace: observability
service: prometheus-server
type: prometheus
type: register-grafana-datasource
type: helm
- name: kube-state-metrics
properties:
chart: kube-state-metrics
repoType: helm
repoUrl: https://prometheus-community.github.io/helm-charts
targetNamespace: observability
version: 3.4.1
type: helm
status:
rollout:
batchRollingState: ""
currentBatch: 0
lastTargetAppRevision: ""
rollingState: ""
upgradedReadyReplicas: 0
upgradedReplicas: 0
dependsOn:
- ref:
apiVersion: core.oam.dev/v1beta1
kind: Initializer
name: fluxcd
namespace: vela-system
- ref:
apiVersion: core.oam.dev/v1beta1
kind: Initializer
name: observability-asset
namespace: vela-system
status:
observedGeneration: 0
@@ -67,6 +67,10 @@ spec:
if parameter.targetNamespace != _|_ {
targetNamespace: parameter.targetNamespace
}
if parameter.releaseName != _|_ {
releaseName: parameter.releaseName
}
if parameter.values != _|_ {
values: parameter.values
}
@@ -91,6 +95,8 @@ spec:
targetNamespace?: string
// +usage=Chart version
value?: #nestedmap
// +usage=The release name
releaseName?: string
}
#nestedmap: {
+2 -2
View File
@@ -15,12 +15,12 @@ spec:
appTemplate:
spec:
components:
{{ range .ResourceFiles }}
{{ range .ResourceFiles }}
- name: {{ .Name }}
type: raw
properties:
{{ .Content | indent 12 }} {{ end }}
{{ range .DefinitionFiles }}
{{ range .DefinitionFiles }}
- name: {{ .Name }}
type: raw
properties:
+6 -1
View File
@@ -21,7 +21,12 @@ spec:
repoType: helm
repoUrl: https://kedacore.github.io/charts
chart: keda
{{ range .DefinitionFiles }}
{{ range .ResourceFiles }}
- name: {{ .Name }}
type: raw
properties:
{{ .Content | indent 12 }} {{ end }}
{{ range .DefinitionFiles }}
- name: {{ .Name }}
type: raw
properties:
+7 -2
View File
@@ -22,9 +22,14 @@ spec:
repoUrl: https://github.com/openkruise/kruise
chart: ./charts/kruise/v0.9.0
branch: master
values:
values:
featureGates: PreDownloadImageForInPlaceUpdate=true
{{ range .DefinitionFiles }}
{{ range .ResourceFiles }}
- name: {{ .Name }}
type: raw
properties:
{{ .Content | indent 12 }} {{ end }}
{{ range .DefinitionFiles }}
- name: {{ .Name }}
type: raw
properties:
@@ -9,12 +9,12 @@ spec:
appTemplate:
spec:
components:
{{ range .ResourceFiles }}
{{ range .ResourceFiles }}
- name: {{ .Name }}
type: raw
properties:
{{ .Content | indent 12 }} {{ end }}
{{ range .DefinitionFiles }}
{{ range .DefinitionFiles }}
- name: {{ .Name }}
type: raw
properties:
@@ -0,0 +1,31 @@
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
annotations:
definition.oam.dev/description: "Add a datasource to Grafana"
name: import-grafana-dashboard
namespace: vela-system
spec:
schematic:
cue:
template: |
outputs: registerdatasource: {
apiVersion: "grafana.extension.oam.dev/v1alpha1"
kind: "ImportDashboard"
spec: {
grafana: {
service: parameter.grafanaServiceName
namespace: parameter.grafanaServiceNamespace
credentialSecret: parameter.credentialSecret
credentialSecretNamespace: parameter.credentialSecretNamespace
}
urls: parameter.urls
}
}
parameter: {
grafanaServiceName: string
grafanaServiceNamespace: *"default" | string
credentialSecret: string
credentialSecretNamespace: *"default" | string
urls: [...string]
}
@@ -0,0 +1,58 @@
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
annotations:
definition.oam.dev/description: "Enable public web traffic for the component without creating a Service."
name: pure-ingress
namespace: vela-system
spec:
status:
customStatus: |-
let igs = context.outputs.ingress.status.loadBalancer.ingress
if igs == _|_ {
message: "No loadBalancer found, visiting by using 'vela port-forward " + context.appName + " --route'\n"
}
if len(igs) > 0 {
if igs[0].ip != _|_ {
message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host + ", IP: " + igs[0].ip
}
if igs[0].ip == _|_ {
message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host
}
}
healthPolicy: |
isHealth: len(context.outputs.ingress.status.loadBalancer.ingress) > 0
schematic:
cue:
template: |
outputs: ingress: {
apiVersion: "networking.k8s.io/v1beta1"
kind: "Ingress"
metadata:
name: context.name
spec: {
rules: [{
host: parameter.domain
http: {
paths: [
for k, v in parameter.http {
path: k
backend: {
serviceName: context.name
servicePort: v
}
},
]
}
}]
}
}
parameter: {
// +usage=Specify the domain you want to expose
domain: string
// +usage=Specify the mapping relationship between the http path and the workload port
http: [string]: int
}
@@ -0,0 +1,42 @@
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
annotations:
definition.oam.dev/description: "Add a datasource to Grafana"
name: register-grafana-datasource
namespace: vela-system
spec:
schematic:
cue:
template: |
outputs: registerdatasource: {
apiVersion: "grafana.extension.oam.dev/v1alpha1"
kind: "DatasourceRegistration"
spec: {
grafana: {
service: parameter.grafanaServiceName
namespace: parameter.grafanaServiceNamespace
credentialSecret: parameter.credentialSecret
credentialSecretNamespace: parameter.credentialSecretNamespace
}
datasource: {
name: parameter.name
type: parameter.type
access: parameter.access
service: parameter.service
namespace: parameter.namespace
}
}
}
parameter: {
grafanaServiceName: string
grafanaServiceNamespace: *"default" | string
credentialSecret: string
credentialSecretNamespace: string
name: string
type: string
access: *"proxy" | string
service: string
namespace: *"default" | string
}
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: observability
@@ -0,0 +1,21 @@
apiVersion: core.oam.dev/v1beta1
kind: Initializer
metadata:
annotations:
addons.oam.dev/description: "Preparations that observability need"
name: observability-asset
namespace: vela-system
spec:
appTemplate:
spec:
components:
{{ range .ResourceFiles }}
- name: {{ .Name }}
type: raw
properties:
{{ .Content | indent 12 }} {{ end }}
{{ range .DefinitionFiles }}
- name: {{ .Name }}
type: raw
properties:
{{ .Content | indent 12 }} {{ end }}
@@ -0,0 +1,128 @@
apiVersion: core.oam.dev/v1beta1
kind: Initializer
metadata:
annotations:
addons.oam.dev/description: "An out of the box solution for KubeVela observability"
name: observability
namespace: observability
spec:
dependsOn:
- ref:
apiVersion: core.oam.dev/v1beta1
kind: Initializer
name: fluxcd
namespace: vela-system
- ref:
apiVersion: core.oam.dev/v1beta1
kind: Initializer
name: observability-asset
namespace: vela-system
appTemplate:
spec:
components:
- name: grafana-registration
type: helm
properties:
repoType: git
repoUrl: https://github.com/oam-dev/grafana-registration
branch: master
chart: ./chart
targetNamespace: observability
values:
replicaCount: 1
- name: grafana
properties:
chart: grafana
version: 6.14.1
repoType: helm
repoUrl: https://grafana.github.io/helm-charts
targetNamespace: observability
releaseName: grafana
type: helm
traits:
- type: pure-ingress
properties:
domain: '[[ index .Args "grafana-domain" ]]'
http:
"/": 80
- type: import-grafana-dashboard
properties:
grafanaServiceName: grafana
grafanaServiceNamespace: observability
credentialSecret: grafana
credentialSecretNamespace: observability
urls:
- https://raw.githubusercontent.com/oam-dev/grafana-registration/master/dashboards/kubevela_core_logging.json
- https://raw.githubusercontent.com/oam-dev/grafana-registration/master/dashboards/kubevela_core_monitoring.json
- name: loki
type: helm
properties:
chart: loki-stack
version: 2.4.1
repoType: helm
repoUrl: https://grafana.github.io/helm-charts
targetNamespace: observability
releaseName: loki
traits:
- type: register-grafana-datasource # register loki datasource to Grafana
properties:
grafanaServiceName: grafana
grafanaServiceNamespace: observability
credentialSecret: grafana
credentialSecretNamespace: observability
name: loki
service: loki
namespace: observability
type: loki
access: proxy
- name: prometheus-server
type: helm
properties:
chart: prometheus
version: 14.4.1
repoType: helm
repoUrl: https://prometheus-community.github.io/helm-charts
targetNamespace: observability
releaseName: prometheus
values:
alertmanager:
persistentVolume:
enabled: '[[ index .Args "alertmanager-pvc-enabled" | default "true" ]]'
storageClass: '[[ index .Args "alertmanager-pvc-class" ]]'
size: '[[ index .Args "alertmanager-pvc-size" | default "20Gi" ]]'
server:
persistentVolume:
enabled: '[[ index .Args "server-pvc-enabled" | default "true" ]]'
storageClass: '[[ index .Args "server-pvc-class" ]]'
size: '[[ index .Args "server-pvc-size" | default "20Gi" ]]'
traits:
- type: register-grafana-datasource # register Prometheus datasource to Grafana
properties:
grafanaServiceName: grafana
grafanaServiceNamespace: observability
credentialSecret: grafana
credentialSecretNamespace: observability
name: prometheus
service: prometheus-server
namespace: observability
type: prometheus
access: proxy
- name: kube-state-metrics
type: helm
properties:
chart: kube-state-metrics
version: 3.4.1
repoType: helm
repoUrl: https://prometheus-community.github.io/helm-charts
targetNamespace: observability
{{ range .ResourceFiles }}
- name: {{ .Name }}
type: raw
properties:
{{ .Content | indent 12 }} {{ end }}
{{ range .DefinitionFiles }}
- name: {{ .Name }}
type: raw
properties:
{{ .Content | indent 12 }} {{ end }}
@@ -9,12 +9,12 @@ spec:
appTemplate:
spec:
components:
{{ range .ResourceFiles }}
{{ range .ResourceFiles }}
- name: {{ .Name }}
type: raw
properties:
{{ .Content | indent 12 }} {{ end }}
{{ range .DefinitionFiles }}
{{ range .DefinitionFiles }}
- name: {{ .Name }}
type: raw
properties:
@@ -21,7 +21,7 @@ spec:
repoType: helm
repoUrl: https://prometheus-community.github.io/helm-charts
chart: premetheus
{{ range .DefinitionFiles }}
{{ range .DefinitionFiles }}
- name: {{ .Name }}
type: raw
properties:
@@ -21,12 +21,12 @@ spec:
repoType: git
repoUrl: https://github.com/oam-dev/terraform-controller
chart: ./chart
{{ range .ResourceFiles }}
{{ range .ResourceFiles }}
- name: {{ .Name }}
type: raw
properties:
{{ .Content | indent 12 }} {{ end }}
{{ range .DefinitionFiles }}
{{ range .DefinitionFiles }}
- name: {{ .Name }}
type: raw
properties:
+8 -7
View File
@@ -31,6 +31,7 @@ import (
"text/template"
"github.com/Masterminds/sprig"
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@@ -181,7 +182,7 @@ func generateInitializer(addon *AddonInfo) (*v1beta1.Initializer, error) {
var buf bytes.Buffer
err = t.Execute(&buf, addon)
if err != nil {
return nil, err
return nil, errors.Wrapf(err, "generate Initializer %s fail", addon.Name)
}
init := new(v1beta1.Initializer)
@@ -266,9 +267,9 @@ func main() {
flag.Parse()
addons, err := walkAllAddons(addonsPath)
dealErr := func(err error) {
dealErr := func(addonName string, err error) {
if err != nil {
fmt.Println(err)
fmt.Printf("%s gen_addon err:%e", addonName, err)
os.Exit(1)
}
}
@@ -278,12 +279,12 @@ func main() {
}
for _, addon := range addons {
addInfo, err := getAddonInfo(addon, addonsPath)
dealErr(err)
dealErr(addon, err)
init, err := generateInitializer(addInfo)
dealErr(err)
dealErr(addon, err)
err = storeInitializer(init, addonsPath, addInfo.Name)
dealErr(err)
dealErr(addon, err)
err = storeConfigMap(addInfo, init, storePath)
dealErr(err)
dealErr(addon, err)
}
}