mirror of
https://github.com/kubevela/kubevela.git
synced 2026-02-14 18:10:21 +00:00
improve helm install
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -46,6 +46,3 @@ dashboard/package-lock.json
|
||||
dashboard/src/.umi/
|
||||
package-lock.json
|
||||
dashboard/src/.umi-production/
|
||||
|
||||
# build
|
||||
charts/vela
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package types
|
||||
|
||||
const (
|
||||
DefaultOAMNS = "oam-system"
|
||||
DefaultOAMReleaseName = "vela-core"
|
||||
DefaultOAMNS = "vela-system"
|
||||
DefaultOAMReleaseName = "kube"
|
||||
DefaultOAMRuntimeChartName = "vela-core"
|
||||
DefaultOAMVersion = ">0.0.0-0"
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
apiVersion: v2
|
||||
name: vela-core
|
||||
description: A Helm chart for Kubernetes
|
||||
description: A Helm chart for Kube Vela core
|
||||
|
||||
# A chart can be either an 'application' or a 'library' chart.
|
||||
#
|
||||
|
||||
@@ -1,465 +0,0 @@
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.2.4
|
||||
creationTimestamp: null
|
||||
name: servicemonitors.monitoring.coreos.com
|
||||
spec:
|
||||
group: monitoring.coreos.com
|
||||
names:
|
||||
kind: ServiceMonitor
|
||||
listKind: ServiceMonitorList
|
||||
plural: servicemonitors
|
||||
singular: servicemonitor
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: ServiceMonitor defines monitoring for a set of services.
|
||||
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: Specification of desired Service selection for target discovery
|
||||
by Prometheus.
|
||||
properties:
|
||||
endpoints:
|
||||
description: A list of endpoints allowed as part of this ServiceMonitor.
|
||||
items:
|
||||
description: Endpoint defines a scrapeable endpoint serving Prometheus
|
||||
metrics.
|
||||
properties:
|
||||
basicAuth:
|
||||
description: 'BasicAuth allow an endpoint to authenticate over
|
||||
basic authentication More info: https://prometheus.io/docs/operating/configuration/#endpoints'
|
||||
properties:
|
||||
password:
|
||||
description: The secret in the service monitor namespace
|
||||
that contains the password for authentication.
|
||||
properties:
|
||||
key:
|
||||
description: The key of the secret to select from. Must
|
||||
be a valid secret key.
|
||||
type: string
|
||||
name:
|
||||
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
|
||||
TODO: Add other useful fields. apiVersion, kind, uid?'
|
||||
type: string
|
||||
optional:
|
||||
description: Specify whether the Secret or its key must
|
||||
be defined
|
||||
type: boolean
|
||||
required:
|
||||
- key
|
||||
type: object
|
||||
username:
|
||||
description: The secret in the service monitor namespace
|
||||
that contains the username for authentication.
|
||||
properties:
|
||||
key:
|
||||
description: The key of the secret to select from. Must
|
||||
be a valid secret key.
|
||||
type: string
|
||||
name:
|
||||
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
|
||||
TODO: Add other useful fields. apiVersion, kind, uid?'
|
||||
type: string
|
||||
optional:
|
||||
description: Specify whether the Secret or its key must
|
||||
be defined
|
||||
type: boolean
|
||||
required:
|
||||
- key
|
||||
type: object
|
||||
type: object
|
||||
bearerTokenFile:
|
||||
description: File to read bearer token for scraping targets.
|
||||
type: string
|
||||
bearerTokenSecret:
|
||||
description: Secret to mount to read bearer token for scraping
|
||||
targets. The secret needs to be in the same namespace as the
|
||||
service monitor and accessible by the Prometheus Operator.
|
||||
properties:
|
||||
key:
|
||||
description: The key of the secret to select from. Must
|
||||
be a valid secret key.
|
||||
type: string
|
||||
name:
|
||||
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
|
||||
TODO: Add other useful fields. apiVersion, kind, uid?'
|
||||
type: string
|
||||
optional:
|
||||
description: Specify whether the Secret or its key must
|
||||
be defined
|
||||
type: boolean
|
||||
required:
|
||||
- key
|
||||
type: object
|
||||
honorLabels:
|
||||
description: HonorLabels chooses the metric's labels on collisions
|
||||
with target labels.
|
||||
type: boolean
|
||||
honorTimestamps:
|
||||
description: HonorTimestamps controls whether Prometheus respects
|
||||
the timestamps present in scraped data.
|
||||
type: boolean
|
||||
interval:
|
||||
description: Interval at which metrics should be scraped
|
||||
type: string
|
||||
metricRelabelings:
|
||||
description: MetricRelabelConfigs to apply to samples before
|
||||
ingestion.
|
||||
items:
|
||||
description: 'RelabelConfig allows dynamic rewriting of the
|
||||
label set, being applied to samples before ingestion. It
|
||||
defines `<metric_relabel_configs>`-section of Prometheus
|
||||
configuration. More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#metric_relabel_configs'
|
||||
properties:
|
||||
action:
|
||||
description: Action to perform based on regex matching.
|
||||
Default is 'replace'
|
||||
type: string
|
||||
modulus:
|
||||
description: Modulus to take of the hash of the source
|
||||
label values.
|
||||
format: int64
|
||||
type: integer
|
||||
regex:
|
||||
description: Regular expression against which the extracted
|
||||
value is matched. Default is '(.*)'
|
||||
type: string
|
||||
replacement:
|
||||
description: Replacement value against which a regex replace
|
||||
is performed if the regular expression matches. Regex
|
||||
capture groups are available. Default is '$1'
|
||||
type: string
|
||||
separator:
|
||||
description: Separator placed between concatenated source
|
||||
label values. default is ';'.
|
||||
type: string
|
||||
sourceLabels:
|
||||
description: The source labels select values from existing
|
||||
labels. Their content is concatenated using the configured
|
||||
separator and matched against the configured regular
|
||||
expression for the replace, keep, and drop actions.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
targetLabel:
|
||||
description: Label to which the resulting value is written
|
||||
in a replace action. It is mandatory for replace actions.
|
||||
Regex capture groups are available.
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
params:
|
||||
additionalProperties:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
description: Optional HTTP URL parameters
|
||||
type: object
|
||||
path:
|
||||
description: HTTP path to scrape for metrics.
|
||||
type: string
|
||||
port:
|
||||
description: Name of the service port this endpoint refers to.
|
||||
Mutually exclusive with targetPort.
|
||||
type: string
|
||||
proxyUrl:
|
||||
description: ProxyURL eg http://proxyserver:2195 Directs scrapes
|
||||
to proxy through this endpoint.
|
||||
type: string
|
||||
relabelings:
|
||||
description: 'RelabelConfigs to apply to samples before scraping.
|
||||
More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config'
|
||||
items:
|
||||
description: 'RelabelConfig allows dynamic rewriting of the
|
||||
label set, being applied to samples before ingestion. It
|
||||
defines `<metric_relabel_configs>`-section of Prometheus
|
||||
configuration. More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#metric_relabel_configs'
|
||||
properties:
|
||||
action:
|
||||
description: Action to perform based on regex matching.
|
||||
Default is 'replace'
|
||||
type: string
|
||||
modulus:
|
||||
description: Modulus to take of the hash of the source
|
||||
label values.
|
||||
format: int64
|
||||
type: integer
|
||||
regex:
|
||||
description: Regular expression against which the extracted
|
||||
value is matched. Default is '(.*)'
|
||||
type: string
|
||||
replacement:
|
||||
description: Replacement value against which a regex replace
|
||||
is performed if the regular expression matches. Regex
|
||||
capture groups are available. Default is '$1'
|
||||
type: string
|
||||
separator:
|
||||
description: Separator placed between concatenated source
|
||||
label values. default is ';'.
|
||||
type: string
|
||||
sourceLabels:
|
||||
description: The source labels select values from existing
|
||||
labels. Their content is concatenated using the configured
|
||||
separator and matched against the configured regular
|
||||
expression for the replace, keep, and drop actions.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
targetLabel:
|
||||
description: Label to which the resulting value is written
|
||||
in a replace action. It is mandatory for replace actions.
|
||||
Regex capture groups are available.
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
scheme:
|
||||
description: HTTP scheme to use for scraping.
|
||||
type: string
|
||||
scrapeTimeout:
|
||||
description: Timeout after which the scrape is ended
|
||||
type: string
|
||||
targetPort:
|
||||
anyOf:
|
||||
- type: integer
|
||||
- type: string
|
||||
description: Name or number of the pod port this endpoint refers
|
||||
to. Mutually exclusive with port.
|
||||
x-kubernetes-int-or-string: true
|
||||
tlsConfig:
|
||||
description: TLS configuration to use when scraping the endpoint
|
||||
properties:
|
||||
ca:
|
||||
description: Stuct containing the CA cert to use for the
|
||||
targets.
|
||||
properties:
|
||||
configMap:
|
||||
description: ConfigMap containing data to use for the
|
||||
targets.
|
||||
properties:
|
||||
key:
|
||||
description: The key to select.
|
||||
type: string
|
||||
name:
|
||||
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
|
||||
TODO: Add other useful fields. apiVersion, kind,
|
||||
uid?'
|
||||
type: string
|
||||
optional:
|
||||
description: Specify whether the ConfigMap or its
|
||||
key must be defined
|
||||
type: boolean
|
||||
required:
|
||||
- key
|
||||
type: object
|
||||
secret:
|
||||
description: Secret containing data to use for the targets.
|
||||
properties:
|
||||
key:
|
||||
description: The key of the secret to select from. Must
|
||||
be a valid secret key.
|
||||
type: string
|
||||
name:
|
||||
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
|
||||
TODO: Add other useful fields. apiVersion, kind,
|
||||
uid?'
|
||||
type: string
|
||||
optional:
|
||||
description: Specify whether the Secret or its key
|
||||
must be defined
|
||||
type: boolean
|
||||
required:
|
||||
- key
|
||||
type: object
|
||||
type: object
|
||||
caFile:
|
||||
description: Path to the CA cert in the Prometheus container
|
||||
to use for the targets.
|
||||
type: string
|
||||
cert:
|
||||
description: Struct containing the client cert file for
|
||||
the targets.
|
||||
properties:
|
||||
configMap:
|
||||
description: ConfigMap containing data to use for the
|
||||
targets.
|
||||
properties:
|
||||
key:
|
||||
description: The key to select.
|
||||
type: string
|
||||
name:
|
||||
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
|
||||
TODO: Add other useful fields. apiVersion, kind,
|
||||
uid?'
|
||||
type: string
|
||||
optional:
|
||||
description: Specify whether the ConfigMap or its
|
||||
key must be defined
|
||||
type: boolean
|
||||
required:
|
||||
- key
|
||||
type: object
|
||||
secret:
|
||||
description: Secret containing data to use for the targets.
|
||||
properties:
|
||||
key:
|
||||
description: The key of the secret to select from. Must
|
||||
be a valid secret key.
|
||||
type: string
|
||||
name:
|
||||
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
|
||||
TODO: Add other useful fields. apiVersion, kind,
|
||||
uid?'
|
||||
type: string
|
||||
optional:
|
||||
description: Specify whether the Secret or its key
|
||||
must be defined
|
||||
type: boolean
|
||||
required:
|
||||
- key
|
||||
type: object
|
||||
type: object
|
||||
certFile:
|
||||
description: Path to the client cert file in the Prometheus
|
||||
container for the targets.
|
||||
type: string
|
||||
insecureSkipVerify:
|
||||
description: Disable target certificate validation.
|
||||
type: boolean
|
||||
keyFile:
|
||||
description: Path to the client key file in the Prometheus
|
||||
container for the targets.
|
||||
type: string
|
||||
keySecret:
|
||||
description: Secret containing the client key file for the
|
||||
targets.
|
||||
properties:
|
||||
key:
|
||||
description: The key of the secret to select from. Must
|
||||
be a valid secret key.
|
||||
type: string
|
||||
name:
|
||||
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
|
||||
TODO: Add other useful fields. apiVersion, kind, uid?'
|
||||
type: string
|
||||
optional:
|
||||
description: Specify whether the Secret or its key must
|
||||
be defined
|
||||
type: boolean
|
||||
required:
|
||||
- key
|
||||
type: object
|
||||
serverName:
|
||||
description: Used to verify the hostname for the targets.
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
type: array
|
||||
jobLabel:
|
||||
description: The label to use to retrieve the job name from.
|
||||
type: string
|
||||
namespaceSelector:
|
||||
description: Selector to select which namespaces the Endpoints objects
|
||||
are discovered from.
|
||||
properties:
|
||||
any:
|
||||
description: Boolean describing whether all namespaces are selected
|
||||
in contrast to a list restricting them.
|
||||
type: boolean
|
||||
matchNames:
|
||||
description: List of namespace names.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
type: object
|
||||
podTargetLabels:
|
||||
description: PodTargetLabels transfers labels on the Kubernetes Pod
|
||||
onto the target.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
sampleLimit:
|
||||
description: SampleLimit defines per-scrape limit on number of scraped
|
||||
samples that will be accepted.
|
||||
format: int64
|
||||
type: integer
|
||||
selector:
|
||||
description: Selector to select Endpoints objects.
|
||||
properties:
|
||||
matchExpressions:
|
||||
description: matchExpressions is a list of label selector requirements.
|
||||
The requirements are ANDed.
|
||||
items:
|
||||
description: A label selector requirement is a selector that
|
||||
contains values, a key, and an operator that relates the key
|
||||
and values.
|
||||
properties:
|
||||
key:
|
||||
description: key is the label key that the selector applies
|
||||
to.
|
||||
type: string
|
||||
operator:
|
||||
description: operator represents a key's relationship to
|
||||
a set of values. Valid operators are In, NotIn, Exists
|
||||
and DoesNotExist.
|
||||
type: string
|
||||
values:
|
||||
description: values is an array of string values. If the
|
||||
operator is In or NotIn, the values array must be non-empty.
|
||||
If the operator is Exists or DoesNotExist, the values
|
||||
array must be empty. This array is replaced during a strategic
|
||||
merge patch.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- key
|
||||
- operator
|
||||
type: object
|
||||
type: array
|
||||
matchLabels:
|
||||
additionalProperties:
|
||||
type: string
|
||||
description: matchLabels is a map of {key,value} pairs. A single
|
||||
{key,value} in the matchLabels map is equivalent to an element
|
||||
of matchExpressions, whose key field is "key", the operator
|
||||
is "In", and the values array contains only "value". The requirements
|
||||
are ANDed.
|
||||
type: object
|
||||
type: object
|
||||
targetLabels:
|
||||
description: TargetLabels transfers labels on the Kubernetes Service
|
||||
onto the target.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- endpoints
|
||||
- selector
|
||||
type: object
|
||||
required:
|
||||
- spec
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
status:
|
||||
acceptedNames:
|
||||
kind: ""
|
||||
plural: ""
|
||||
conditions: []
|
||||
storedVersions: []
|
||||
@@ -1,5 +1,4 @@
|
||||
---
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
@@ -24,7 +23,6 @@ kind: ServiceAccount
|
||||
metadata:
|
||||
name: cert-manager
|
||||
namespace: "cert-manager"
|
||||
annotations:
|
||||
labels:
|
||||
app: cert-manager
|
||||
app.kubernetes.io/name: cert-manager
|
||||
|
||||
@@ -18,7 +18,7 @@ metadata:
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: manager-rolebinding
|
||||
name: {{ include "kubevela.fullname" . }}:manager-rolebinding
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
@@ -33,7 +33,7 @@ subjects:
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: leader-election-role
|
||||
name: {{ include "kubevela.fullname" . }}:leader-election-role
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
@@ -66,11 +66,11 @@ rules:
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: leader-election-rolebinding
|
||||
name: {{ include "kubevela.fullname" . }}:leader-election-rolebinding
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: leader-election-role
|
||||
name: {{ include "kubevela.fullname" . }}:leader-election-role
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ include "kubevela.serviceAccountName" . }}
|
||||
@@ -80,6 +80,7 @@ apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "kubevela.fullname" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "kubevela.labels" . | nindent 4 }}
|
||||
spec:
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
labels:
|
||||
mornitoring: oam
|
||||
name: monitoring
|
||||
|
||||
---
|
||||
apiVersion: core.oam.dev/v1alpha2
|
||||
kind: TraitDefinition
|
||||
metadata:
|
||||
|
||||
@@ -2,7 +2,7 @@ apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: vela-config
|
||||
namespace: default
|
||||
namespace: {{ .Release.Namespace }}
|
||||
data:
|
||||
certificates.cert-manager.io: |
|
||||
{
|
||||
@@ -11,12 +11,12 @@ data:
|
||||
"name": "cert-manager",
|
||||
"namespace": "cert-manager",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
}
|
||||
servicemonitors.monitoring.coreos.com: |
|
||||
{
|
||||
"repo": "jetstack",
|
||||
"urL": "https://charts.jetstack.io",
|
||||
"name": "cert-manager",
|
||||
"namespace": "cert-manager",
|
||||
"version": "1.0.0"
|
||||
"repo": "prometheus-community",
|
||||
"urL": "https://prometheus-community.github.io/helm-charts",
|
||||
"name": "kube-prometheus-stack",
|
||||
"namespace": "monitoring",
|
||||
"version": "9.4.4"
|
||||
}
|
||||
@@ -3,8 +3,8 @@
|
||||
apiVersion: admissionregistration.k8s.io/v1beta1
|
||||
kind: MutatingWebhookConfiguration
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: mutating-webhook-configuration
|
||||
namespace: {{ .Release.Namespace }}
|
||||
annotations:
|
||||
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ .Values.certificate.certificateName }}
|
||||
webhooks:
|
||||
@@ -49,8 +49,8 @@ webhooks:
|
||||
apiVersion: admissionregistration.k8s.io/v1beta1
|
||||
kind: ValidatingWebhookConfiguration
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: validating-webhook-configuration
|
||||
namespace: {{ .Release.Namespace }}
|
||||
annotations:
|
||||
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ .Values.certificate.certificateName }}
|
||||
webhooks:
|
||||
@@ -98,6 +98,7 @@ apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ template "kubevela.name" . }}-webhook
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "kubevela.labels" . | nindent 4 }}
|
||||
spec:
|
||||
|
||||
@@ -6,23 +6,17 @@ import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
velacore "github.com/oam-dev/kubevela/api/v1alpha1"
|
||||
velacontroller "github.com/oam-dev/kubevela/pkg/controller"
|
||||
"github.com/oam-dev/kubevela/pkg/controller/dependency"
|
||||
velawebhook "github.com/oam-dev/kubevela/pkg/webhook"
|
||||
|
||||
monitoring "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1"
|
||||
"github.com/crossplane/crossplane-runtime/pkg/logging"
|
||||
oamcore "github.com/crossplane/oam-kubernetes-runtime/apis/core"
|
||||
oamcontroller "github.com/crossplane/oam-kubernetes-runtime/pkg/controller"
|
||||
oamv1alpha2 "github.com/crossplane/oam-kubernetes-runtime/pkg/controller/v1alpha2"
|
||||
oamwebhook "github.com/crossplane/oam-kubernetes-runtime/pkg/webhook/v1alpha2"
|
||||
certmanager "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha2"
|
||||
injectorv1alpha1 "github.com/oam-dev/trait-injector/api/v1alpha1"
|
||||
injectorcontroller "github.com/oam-dev/trait-injector/controllers"
|
||||
"github.com/oam-dev/trait-injector/pkg/injector"
|
||||
"github.com/oam-dev/trait-injector/pkg/plugin"
|
||||
|
||||
monitoring "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1"
|
||||
"github.com/crossplane/crossplane-runtime/pkg/logging"
|
||||
certmanager "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha2"
|
||||
"go.uber.org/zap/zapcore"
|
||||
"gopkg.in/natefinch/lumberjack.v2"
|
||||
crdv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||
@@ -31,6 +25,11 @@ import (
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/log/zap"
|
||||
|
||||
velacore "github.com/oam-dev/kubevela/api/v1alpha1"
|
||||
velacontroller "github.com/oam-dev/kubevela/pkg/controller"
|
||||
"github.com/oam-dev/kubevela/pkg/controller/dependency"
|
||||
velawebhook "github.com/oam-dev/kubevela/pkg/webhook"
|
||||
)
|
||||
|
||||
var scheme = runtime.NewScheme()
|
||||
@@ -88,6 +87,17 @@ func main() {
|
||||
}))
|
||||
|
||||
setupLog := ctrl.Log.WithName("vela-runtime")
|
||||
// install dependency charts first
|
||||
k8sClient, err := client.New(ctrl.GetConfigOrDie(), client.Options{Scheme: scheme})
|
||||
if err != nil {
|
||||
setupLog.Error(err, "unable to create a kubernetes client")
|
||||
os.Exit(1)
|
||||
}
|
||||
if err = dependency.Install(k8sClient); err != nil {
|
||||
setupLog.Error(err, "unable to install the dependency")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
|
||||
Scheme: scheme,
|
||||
MetricsBindAddress: metricsAddr,
|
||||
@@ -101,17 +111,6 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
k8sClient, err := client.New(ctrl.GetConfigOrDie(), client.Options{Scheme: scheme})
|
||||
if err != nil {
|
||||
setupLog.Error(err, "unable to create a kubernetes client")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if err = dependency.Install(k8sClient); err != nil {
|
||||
setupLog.Error(err, "unable to install the dependency")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if useWebhook {
|
||||
setupLog.Info("vela webhook enabled, will serving at :" + strconv.Itoa(webhookPort))
|
||||
oamwebhook.Add(mgr)
|
||||
|
||||
@@ -12,10 +12,11 @@ data:
|
||||
"namespace": "cert-manager",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
ingresses.networking.k8s.io: |
|
||||
servicemonitors.monitoring.coreos.com: |
|
||||
{
|
||||
"repo": "stable",
|
||||
"urL": "https://kubernetes-charts.storage.googleapis.com/",
|
||||
"name": "nginx-ingress",
|
||||
"version": "1.41.2"
|
||||
"repo": "prometheus-community",
|
||||
"urL": "https://prometheus-community.github.io/helm-charts",
|
||||
"name": "kube-prometheus-stack",
|
||||
"namespace": "monitoring",
|
||||
"version": "9.4.4"
|
||||
}
|
||||
@@ -45,7 +45,7 @@ func RefreshDefinitions(ctx context.Context, c client.Client, ioStreams cmdutil.
|
||||
return err
|
||||
}
|
||||
syncedTemplates = append(syncedTemplates, templates...)
|
||||
ioStreams.Infof("get %d workload definition(s) from cluster, syncing...", len(templates))
|
||||
ioStreams.Infof("get %d workload definition(s) from cluster, syncing...\n", len(templates))
|
||||
successNum := plugins.SinkTemp2Local(templates, dir)
|
||||
ioStreams.Infof("sync %d workload definition(s) successfully\n", successNum)
|
||||
|
||||
@@ -55,7 +55,7 @@ func RefreshDefinitions(ctx context.Context, c client.Client, ioStreams cmdutil.
|
||||
return err
|
||||
}
|
||||
syncedTemplates = append(syncedTemplates, templates...)
|
||||
ioStreams.Infof("get %d trait definition(s) from cluster, syncing...", len(templates))
|
||||
ioStreams.Infof("get %d trait definition(s) from cluster, syncing...\n", len(templates))
|
||||
successNum = plugins.SinkTemp2Local(templates, dir)
|
||||
ioStreams.Infof("sync %d trait definition(s) successfully\n", successNum)
|
||||
|
||||
|
||||
@@ -5,13 +5,11 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
oamv1 "github.com/crossplane/oam-kubernetes-runtime/apis/core/v1alpha2"
|
||||
"github.com/openservicemesh/osm/pkg/cli"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"helm.sh/helm/v3/pkg/chart"
|
||||
"helm.sh/helm/v3/pkg/chart/loader"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
"github.com/oam-dev/kubevela/api/types"
|
||||
@@ -30,19 +28,6 @@ type infoCmd struct {
|
||||
out io.Writer
|
||||
}
|
||||
|
||||
var (
|
||||
defaultObject = []interface{}{
|
||||
&oamv1.WorkloadDefinition{},
|
||||
&oamv1.ApplicationConfiguration{},
|
||||
&oamv1.Component{},
|
||||
&oamv1.TraitDefinition{},
|
||||
&oamv1.ContainerizedWorkload{},
|
||||
&oamv1.HealthScope{},
|
||||
&oamv1.ManualScalerTrait{},
|
||||
&oamv1.ScopeDefinition{},
|
||||
}
|
||||
)
|
||||
|
||||
func SystemCommandGroup(c types.Args, ioStream cmdutil.IOStreams) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "system",
|
||||
@@ -85,7 +70,7 @@ func (i *infoCmd) run(ioStreams cmdutil.IOStreams) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewInstallCommand(c types.Args, chartSource string, ioStreams cmdutil.IOStreams) *cobra.Command {
|
||||
func NewInstallCommand(c types.Args, chartContent string, ioStreams cmdutil.IOStreams) *cobra.Command {
|
||||
i := &initCmd{ioStreams: ioStreams}
|
||||
cmd := &cobra.Command{
|
||||
Use: "install",
|
||||
@@ -98,7 +83,7 @@ func NewInstallCommand(c types.Args, chartSource string, ioStreams cmdutil.IOStr
|
||||
}
|
||||
i.client = newClient
|
||||
i.namespace = types.DefaultOAMNS
|
||||
return i.run(ioStreams, chartSource)
|
||||
return i.run(ioStreams, chartContent)
|
||||
},
|
||||
Annotations: map[string]string{
|
||||
types.TagCommandType: types.TypeStart,
|
||||
@@ -117,52 +102,52 @@ func (i *initCmd) run(ioStreams cmdutil.IOStreams, chartSource string) error {
|
||||
if err := cmdutil.NewNamespace(i.client, types.DefaultOAMNS); err != nil {
|
||||
return err
|
||||
}
|
||||
ioStreams.Info("created namespace", types.DefaultOAMNS)
|
||||
}
|
||||
|
||||
if i.IsOamRuntimeExist() {
|
||||
if oam.IsHelmReleaseRunning(types.DefaultOAMReleaseName, types.DefaultOAMRuntimeChartName, i.ioStreams) {
|
||||
i.ioStreams.Info("Vela system along with OAM runtime already exist.")
|
||||
} else {
|
||||
if err := InstallOamRuntime(i.chartPath, chartSource); err != nil {
|
||||
if err := InstallOamRuntime(i.chartPath, chartSource, ioStreams); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
ioStreams.Info()
|
||||
if err := RefreshDefinitions(context.Background(), i.client, ioStreams); err != nil {
|
||||
return err
|
||||
}
|
||||
ioStreams.Info("- Finished.")
|
||||
ioStreams.Info("- Finished successfully.")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *initCmd) IsOamRuntimeExist() bool {
|
||||
for _, object := range defaultObject {
|
||||
if err := cmdutil.IsCoreCRDExist(context.Background(), i.client, object.(runtime.Object)); err != nil {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return oam.IsHelmReleaseRunning(types.DefaultOAMReleaseName, types.DefaultOAMRuntimeChartName, i.ioStreams)
|
||||
}
|
||||
|
||||
func InstallOamRuntime(chartPath, chartSource string) error {
|
||||
func InstallOamRuntime(chartPath, chartSource string, ioStreams cmdutil.IOStreams) error {
|
||||
var err error
|
||||
var chartRequested *chart.Chart
|
||||
if chartPath != "" {
|
||||
ioStreams.Infof("Use customized chart at: %s", chartPath)
|
||||
chartRequested, err = loader.Load(chartPath)
|
||||
} else {
|
||||
chartRequested, err = cli.LoadChart(chartSource)
|
||||
ioStreams.Infof("install chart %s, version %s, desc : %s, contains %d file\n",
|
||||
chartRequested.Metadata.Name, chartRequested.Metadata.Version, chartRequested.Metadata.Description,
|
||||
len(chartRequested.Raw))
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("error loading chart for installation: %s", err)
|
||||
}
|
||||
installClient, err := oam.NewHelmInstall("", "", types.DefaultOAMReleaseName)
|
||||
installClient, err := oam.NewHelmInstall("", types.DefaultOAMNS, types.DefaultOAMReleaseName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error create helm install client: %s", err)
|
||||
}
|
||||
//TODO(wonderflow) values here could give more arguments in command line
|
||||
if _, err = installClient.Run(chartRequested, nil); err != nil {
|
||||
release, err := installClient.Run(chartRequested, nil)
|
||||
if err != nil {
|
||||
ioStreams.Errorf("Failed to install the chart with error: %+v\n", err)
|
||||
return err
|
||||
}
|
||||
ioStreams.Infof("Successfully installed the chart, status: %s, last deployed time = %s\n",
|
||||
release.Info.Status,
|
||||
release.Info.LastDeployed.String())
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -1,45 +1,144 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
"k8s.io/client-go/discovery"
|
||||
diskcached "k8s.io/client-go/discovery/cached/disk"
|
||||
"k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/restmapper"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"k8s.io/client-go/util/homedir"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
)
|
||||
|
||||
type Factory interface {
|
||||
genericclioptions.RESTClientGetter
|
||||
var defaultCacheDir = filepath.Join(homedir.HomeDir(), ".kube", "http-cache")
|
||||
|
||||
var _ genericclioptions.RESTClientGetter = &restConfigGetter{}
|
||||
|
||||
// The helm client never thought it could be used inside a cluster so it
|
||||
// took a dependency on the kube cli, we have to create a cli client getter from the rest.Config
|
||||
func NewRestConfigGetter(namespace string) genericclioptions.RESTClientGetter {
|
||||
return &restConfigGetter{
|
||||
config: ctrl.GetConfigOrDie(),
|
||||
namespace: namespace,
|
||||
}
|
||||
}
|
||||
|
||||
type factoryImpl struct {
|
||||
clientGetter genericclioptions.RESTClientGetter
|
||||
type restConfigGetter struct {
|
||||
config *rest.Config
|
||||
namespace string
|
||||
}
|
||||
|
||||
func (f *factoryImpl) ToRESTConfig() (*rest.Config, error) {
|
||||
return f.clientGetter.ToRESTConfig()
|
||||
func (r *restConfigGetter) ToRESTConfig() (*rest.Config, error) {
|
||||
return r.config, nil
|
||||
}
|
||||
|
||||
func (f *factoryImpl) ToRESTMapper() (meta.RESTMapper, error) {
|
||||
return f.clientGetter.ToRESTMapper()
|
||||
}
|
||||
|
||||
func (f *factoryImpl) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error) {
|
||||
return f.clientGetter.ToDiscoveryClient()
|
||||
}
|
||||
|
||||
func (f *factoryImpl) ToRawKubeConfigLoader() clientcmd.ClientConfig {
|
||||
return f.clientGetter.ToRawKubeConfigLoader()
|
||||
}
|
||||
|
||||
func NewFactory(clientGetter genericclioptions.RESTClientGetter) Factory {
|
||||
if clientGetter == nil {
|
||||
panic("attempt to instantiate client_access_factory with nil clientGetter")
|
||||
// ToDiscoveryClient implements RESTClientGetter.
|
||||
// Expects the AddFlags method to have been called.
|
||||
// Returns a CachedDiscoveryInterface using a computed RESTConfig.
|
||||
func (r *restConfigGetter) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error) {
|
||||
config, err := r.ToRESTConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
f := &factoryImpl{
|
||||
clientGetter: clientGetter,
|
||||
// The more groups you have, the more discovery requests you need to make.
|
||||
// given 25 groups (our groups + a few custom resources) with one-ish version each, discovery needs to make 50 requests
|
||||
// double it just so we don't end up here again for a while. This config is only used for discovery.
|
||||
config.Burst = 100
|
||||
|
||||
// retrieve a user-provided value for the "cache-dir"
|
||||
// defaulting to ~/.kube/http-cache if no user-value is given.
|
||||
httpCacheDir := defaultCacheDir
|
||||
|
||||
discoveryCacheDir := computeDiscoverCacheDir(filepath.Join(homedir.HomeDir(), ".kube", "cache", "discovery"), config.Host)
|
||||
return diskcached.NewCachedDiscoveryClientForConfig(config, discoveryCacheDir, httpCacheDir, time.Duration(10*time.Minute))
|
||||
}
|
||||
|
||||
// ToRESTMapper returns a mapper.
|
||||
func (r *restConfigGetter) ToRESTMapper() (meta.RESTMapper, error) {
|
||||
discoveryClient, err := r.ToDiscoveryClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return f
|
||||
mapper := restmapper.NewDeferredDiscoveryRESTMapper(discoveryClient)
|
||||
expander := restmapper.NewShortcutExpander(mapper, discoveryClient)
|
||||
return expander, nil
|
||||
}
|
||||
|
||||
func (r *restConfigGetter) ToRawKubeConfigLoader() clientcmd.ClientConfig {
|
||||
loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
|
||||
// use the standard defaults for this client command
|
||||
// DEPRECATED: remove and replace with something more accurate
|
||||
loadingRules.DefaultClientConfig = &clientcmd.DefaultClientConfig
|
||||
|
||||
overrides := &clientcmd.ConfigOverrides{ClusterDefaults: clientcmd.ClusterDefaults}
|
||||
|
||||
// bind auth info flag values to overrides
|
||||
if r.config.CertFile != "" {
|
||||
overrides.AuthInfo.ClientCertificate = r.config.CertFile
|
||||
}
|
||||
if r.config.KeyFile != "" {
|
||||
overrides.AuthInfo.ClientKey = r.config.KeyFile
|
||||
}
|
||||
if r.config.BearerToken != "" {
|
||||
overrides.AuthInfo.Token = r.config.BearerToken
|
||||
}
|
||||
|
||||
overrides.AuthInfo.Impersonate = r.config.Impersonate.UserName
|
||||
overrides.AuthInfo.ImpersonateGroups = r.config.Impersonate.Groups
|
||||
overrides.AuthInfo.ImpersonateUserExtra = r.config.Impersonate.Extra
|
||||
|
||||
if r.config.Username != "" {
|
||||
overrides.AuthInfo.Username = r.config.Username
|
||||
}
|
||||
if r.config.Password != "" {
|
||||
overrides.AuthInfo.Password = r.config.Password
|
||||
}
|
||||
|
||||
// bind cluster flags
|
||||
if r.config.Host != "" {
|
||||
overrides.ClusterInfo.Server = r.config.Host
|
||||
}
|
||||
if r.config.CAFile != "" {
|
||||
overrides.ClusterInfo.CertificateAuthority = r.config.CAFile
|
||||
}
|
||||
overrides.ClusterInfo.InsecureSkipTLSVerify = r.config.Insecure
|
||||
|
||||
if r.config.Timeout != 0 {
|
||||
overrides.Timeout = r.config.Timeout.String()
|
||||
}
|
||||
// set namespace
|
||||
overrides.Context.Namespace = r.namespace
|
||||
|
||||
var clientConfig clientcmd.ClientConfig
|
||||
|
||||
// we only have an interactive prompt when a password is allowed
|
||||
if r.config.Password == "" {
|
||||
clientConfig = clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, overrides)
|
||||
} else {
|
||||
clientConfig = clientcmd.NewInteractiveDeferredLoadingClientConfig(loadingRules, overrides, os.Stdin)
|
||||
}
|
||||
|
||||
return clientConfig
|
||||
}
|
||||
|
||||
// overlyCautiousIllegalFileCharacters matches characters that *might* not be supported. Windows is really restrictive, so this is really restrictive
|
||||
var overlyCautiousIllegalFileCharacters = regexp.MustCompile(`[^(\w/\.)]`)
|
||||
|
||||
// computeDiscoverCacheDir takes the parentDir and the host and comes up with a "usually non-colliding" name.
|
||||
func computeDiscoverCacheDir(parentDir, host string) string {
|
||||
// strip the optional scheme from host if its there:
|
||||
schemelessHost := strings.Replace(strings.Replace(host, "https://", "", 1), "http://", "", 1)
|
||||
// now do a simple collapse of non-AZ09 characters. Collisions are possible but unlikely. Even if we do collide the problem is short lived
|
||||
safeHost := overlyCautiousIllegalFileCharacters.ReplaceAllString(schemelessHost, "_")
|
||||
return filepath.Join(parentDir, safeHost)
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ func init() {
|
||||
func Install(client client.Client) error {
|
||||
log := ctrl.Log.WithName("vela dependency manager")
|
||||
// Fetch the vela configuration
|
||||
velaConfigNN := k8stypes.NamespacedName{Name: VelaConfigName, Namespace: types.DefaultAppNamespace}
|
||||
velaConfigNN := k8stypes.NamespacedName{Name: VelaConfigName, Namespace: types.DefaultOAMNS}
|
||||
velaConfig := v1.ConfigMap{}
|
||||
if err := client.Get(context.TODO(), velaConfigNN, &velaConfig); err != nil {
|
||||
return err
|
||||
|
||||
@@ -76,7 +76,7 @@ func NewHelmInstall(version, namespace, releaseName string) (*action.Install, er
|
||||
namespace = types.DefaultOAMNS
|
||||
}
|
||||
if err := actionConfig.Init(
|
||||
kube.GetConfig(cmdutil.GetKubeConfig(), "", types.DefaultOAMNS),
|
||||
cmdutil.NewRestConfigGetter(namespace),
|
||||
namespace,
|
||||
os.Getenv("HELM_DRIVER"),
|
||||
debug,
|
||||
|
||||
Reference in New Issue
Block a user