Skip to content
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
33 changes: 33 additions & 0 deletions manifests/charts/dubbo-cni/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v2
annotations:
licenses: Apache-2.0
name: dubbo-cni
home: https://github.com/apache/dubbo-kubernetes
description: Helm chart for Dubbo CNI node-level Triple tunnel DaemonSet.
keywords:
- dubbo
- dubbo-cni
- cni
- ambient
- triple
version: 0.4.7
appVersion: "arm64"
sources:
- https://dubbo.apache.org
- https://github.com/dubml
- https://github.com/apache/dubbo-kubernetes
28 changes: 28 additions & 0 deletions manifests/charts/dubbo-cni/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: dubbo-cni-node
labels:
app: dubbo-cni-node
rules:
- apiGroups: [""]
resources: ["pods", "namespaces", "secrets", "nodes"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["events"]
verbs: ["create", "patch"]
29 changes: 29 additions & 0 deletions manifests/charts/dubbo-cni/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: dubbo-cni-node
labels:
app: dubbo-cni-node
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: dubbo-cni-node
subjects:
- kind: ServiceAccount
name: dubbo-cni-node
namespace: {{ .Release.Namespace }}
144 changes: 144 additions & 0 deletions manifests/charts/dubbo-cni/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

{{- $defaults := .Values._internal_default_values_not_set | default dict }}
{{- $repo := coalesce .Values.repo $defaults.repo "dubml" }}
{{- $tag := .Chart.AppVersion }}
{{- if and (hasKey .Values "tag") (ne (.Values.tag | toString) "") }}
{{- $tag = .Values.tag }}
{{- else if and (hasKey $defaults "tag") (ne ($defaults.tag | toString) "") }}
{{- $tag = $defaults.tag }}
{{- end }}
{{- $image := coalesce .Values.image $defaults.image "dubbo-cni" }}
{{- if not (contains "/" $image) }}
{{- $image = printf "%s/%s:%v" $repo $image $tag }}
{{- end }}
{{- $cniBinDir := coalesce .Values.cniBinDir $defaults.cniBinDir "/opt/cni/bin" }}
{{- $cniNetDir := coalesce .Values.cniNetDir $defaults.cniNetDir "/etc/cni/net.d" }}
{{- $socketPath := coalesce .Values.socketPath $defaults.socketPath "/var/run/dubbo-cni/cni.sock" }}
{{- $statusPort := coalesce .Values.statusPort $defaults.statusPort 15021 }}
{{- $outboundPort := coalesce .Values.outboundPort $defaults.outboundPort 15001 }}
{{- $inboundTunnelPort := coalesce .Values.inboundTunnelPort $defaults.inboundTunnelPort 15008 }}
{{- $discoveryAddress := coalesce .Values.discoveryAddress $defaults.discoveryAddress "dubbod.dubbo-system.svc:26012" }}
{{- $excludeNamespaces := coalesce .Values.excludeNamespaces $defaults.excludeNamespaces "kube-system,dubbo-system" }}
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: dubbo-cni-node
namespace: {{ .Release.Namespace }}
labels:
app: dubbo-cni-node
spec:
selector:
matchLabels:
app: dubbo-cni-node
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
template:
metadata:
labels:
app: dubbo-cni-node
annotations:
prometheus.io/scrape: "true"
prometheus.io/path: "/metrics"
prometheus.io/port: "{{ $statusPort }}"
spec:
serviceAccountName: dubbo-cni-node
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
priorityClassName: system-node-critical
tolerations:
- operator: Exists
containers:
- name: cni-node
image: {{ $image }}
imagePullPolicy: {{ coalesce .Values.imagePullPolicy $defaults.imagePullPolicy "IfNotPresent" }}
args:
- --cni-bin-dir=/host/opt/cni/bin
- --cni-net-dir=/host/etc/cni/net.d
- --socket-path={{ $socketPath }}
- --status-addr=:{{ $statusPort }}
- --outbound-addr=:{{ $outboundPort }}
- --inbound-tunnel-addr=:{{ $inboundTunnelPort }}
- --exclude-namespaces={{ $excludeNamespaces }}
env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: NODE_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: DUBBO_SYSTEM_NAMESPACE
value: {{ .Release.Namespace }}
- name: XDS_ADDRESS
value: {{ $discoveryAddress }}
ports:
- name: status
containerPort: {{ $statusPort }}
protocol: TCP
- name: outbound
containerPort: {{ $outboundPort }}
protocol: TCP
- name: tunnel
containerPort: {{ $inboundTunnelPort }}
protocol: TCP
securityContext:
privileged: true
capabilities:
add:
- NET_ADMIN
- NET_RAW
- SYS_ADMIN
livenessProbe:
httpGet:
path: /healthz
port: {{ $statusPort }}
initialDelaySeconds: 5
periodSeconds: 10
readinessProbe:
httpGet:
path: /readyz
port: {{ $statusPort }}
initialDelaySeconds: 2
periodSeconds: 5
volumeMounts:
- name: cni-bin-dir
mountPath: /host/opt/cni/bin
- name: cni-net-dir
mountPath: /host/etc/cni/net.d
- name: cni-socket-dir
mountPath: /var/run/dubbo-cni
- name: host-netns
mountPath: /var/run/netns
mountPropagation: HostToContainer
volumes:
- name: cni-bin-dir
hostPath:
path: {{ $cniBinDir }}
- name: cni-net-dir
hostPath:
path: {{ $cniNetDir }}
- name: cni-socket-dir
hostPath:
path: /var/run/dubbo-cni
type: DirectoryOrCreate
- name: host-netns
hostPath:
path: /var/run/netns
type: DirectoryOrCreate
22 changes: 22 additions & 0 deletions manifests/charts/dubbo-cni/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: ServiceAccount
metadata:
name: dubbo-cni-node
namespace: {{ .Release.Namespace }}
labels:
app: dubbo-cni-node
30 changes: 30 additions & 0 deletions manifests/charts/dubbo-cni/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

_internal_default_values_not_set:
repo: ""
tag: ""
image: dubbo-cni
cniBinDir: /opt/cni/bin
cniNetDir: /etc/cni/net.d
cniConfName: ""
socketPath: /var/run/dubbo-cni/cni.sock
excludeNamespaces: "kube-system,dubbo-system"
failOpen: false
discoveryAddress: "dubbod.dubbo-system.svc:26012"
statusPort: 15021
outboundPort: 15001
inboundTunnelPort: 15008
imagePullPolicy: IfNotPresent
2 changes: 2 additions & 0 deletions manifests/profiles/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ spec:
enabled: true
dubbod:
enabled: true
cni:
enabled: true
values: {}

7 changes: 7 additions & 0 deletions operator/pkg/apis/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ type DubboComponentSpec struct {
Base *BaseComponentSpec `json:"base,omitempty"`
// Using dubbod as the control plane.
Dubbod *DiscoveryComponentSpec `json:"dubbod,omitempty"`
// Using dubbo-cni-node as the node-level CNI tunnel agent.
Cni *CNIComponentSpec `json:"cni,omitempty"`
}

type BaseComponentSpec struct {
Expand All @@ -70,6 +72,11 @@ type DiscoveryComponentSpec struct {
Enabled *BoolValue `json:"enabled,omitempty"`
}

type CNIComponentSpec struct {
// Selects whether this component is installed.
Enabled *BoolValue `json:"enabled,omitempty"`
}

type DefaultCompSpec struct {
// Selects whether this component is installed.
Enabled *BoolValue `json:"enabled,omitempty"`
Expand Down
12 changes: 12 additions & 0 deletions operator/pkg/component/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type Name string
const (
BaseComponentName Name = "Base"
DubboDiscoveryComponentName Name = "Dubbod"
CniComponentName Name = "Cni"
)

type Component struct {
Expand Down Expand Up @@ -66,17 +67,28 @@ var AllComponents = []Component{
Default: true,
HelmSubDir: "dubbod",
},
{
UserFacingName: CniComponentName,
SpecName: "cni",
ResourceType: "DaemonSet",
ResourceName: "dubbo-cni-node",
ContainerName: "cni-node",
Default: true,
HelmSubDir: "dubbo-cni",
},
}

var (
userFacingCompNames = map[Name]string{
BaseComponentName: "Dubbo Resource Core",
DubboDiscoveryComponentName: "Dubbo control plane",
CniComponentName: "Dubbo CNI node agent",
}

Icons = map[Name]string{
BaseComponentName: "⚡️",
DubboDiscoveryComponentName: "⚡️",
CniComponentName: "⚡️",
}
)

Expand Down
5 changes: 4 additions & 1 deletion operator/pkg/install/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,10 @@ func (i Installer) prune(manifests []manifest.ManifestSet) error {
}

var componentDependencies = map[component.Name][]component.Name{
component.DubboDiscoveryComponentName: {},
component.CniComponentName: {},
component.DubboDiscoveryComponentName: {
component.CniComponentName,
},
component.BaseComponentName: {
component.DubboDiscoveryComponentName,
},
Expand Down
15 changes: 15 additions & 0 deletions operator/pkg/render/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,3 +371,18 @@ func hasContainerPort(ports []interface{}, name string, number int64) bool {
}
return false
}

func TestGenerateManifestRendersDubboCNIDaemonSet(t *testing.T) {
manifests, _, err := GenerateManifest(nil, nil, nil, nil)
if err != nil {
t.Fatalf("GenerateManifest() error = %v", err)
}
ds := findManifest(t, manifests, "DaemonSet", "dubbo-cni-node")
hostNetwork, ok, err := unstructured.NestedBool(ds.Object, "spec", "template", "spec", "hostNetwork")
if err != nil || !ok || !hostNetwork {
t.Fatalf("dubbo-cni-node hostNetwork = %v (ok=%v err=%v), want true", hostNetwork, ok, err)
}
findManifest(t, manifests, "ServiceAccount", "dubbo-cni-node")
findManifest(t, manifests, "ClusterRole", "dubbo-cni-node")
findManifest(t, manifests, "ClusterRoleBinding", "dubbo-cni-node")
}
1 change: 1 addition & 0 deletions operator/pkg/uninstall/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func GetRemovedResources(kc kube.CLIClient, dopName, dopNamespace string, includ
} else {
includeCN := []string{
string(component.DubboDiscoveryComponentName),
string(component.CniComponentName),
}
includeRequirement, lerr := klabels.NewRequirement(manifest.DubboComponentLabel, selection.In, includeCN)
if lerr != nil {
Expand Down
Loading