Skip to content

Commit b907eb3

Browse files
committed
add multi-cluster deployment support via Cluster Inventory API
Signed-off-by: kahirokunn <okinakahiro@gmail.com>
1 parent 4ad2f43 commit b907eb3

196 files changed

Lines changed: 13807 additions & 4067 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmd/operator/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ limitations under the License.
1717
package main
1818

1919
import (
20+
// Register --clusterprofile-provider-file before sharedmain parses flags.
21+
_ "knative.dev/operator/pkg/reconciler/common"
2022
"knative.dev/operator/pkg/reconciler/knativeeventing"
2123
"knative.dev/operator/pkg/reconciler/knativeserving"
2224
kubefilteredfactory "knative.dev/pkg/client/injection/kube/informers/factory/filtered"

config/charts/knative-operator/templates/crds/knativeeventings.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,23 @@ spec:
6969
- URL
7070
type: object
7171
type: array
72+
clusterProfileRef:
73+
description: |-
74+
ClusterProfileRef is an optional reference to a ClusterProfile resource
75+
(multicluster.x-k8s.io/v1alpha1). When set, the operator reconciles
76+
the component on the remote cluster described by the referenced
77+
ClusterProfile instead of the local cluster.
78+
properties:
79+
name:
80+
description: Name is the name of the ClusterProfile resource.
81+
type: string
82+
namespace:
83+
description: Namespace is the namespace of the ClusterProfile resource.
84+
type: string
85+
required:
86+
- name
87+
- namespace
88+
type: object
7289
config:
7390
additionalProperties:
7491
additionalProperties:

config/charts/knative-operator/templates/crds/knativeservings.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,23 @@ spec:
6969
- URL
7070
type: object
7171
type: array
72+
clusterProfileRef:
73+
description: |-
74+
ClusterProfileRef is an optional reference to a ClusterProfile resource
75+
(multicluster.x-k8s.io/v1alpha1). When set, the operator reconciles
76+
the component on the remote cluster described by the referenced
77+
ClusterProfile instead of the local cluster.
78+
properties:
79+
name:
80+
description: Name is the name of the ClusterProfile resource.
81+
type: string
82+
namespace:
83+
description: Namespace is the namespace of the ClusterProfile resource.
84+
type: string
85+
required:
86+
- name
87+
- namespace
88+
type: object
7289
config:
7390
additionalProperties:
7491
additionalProperties:
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2025 The Knative Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
{{- $mc := .Values.knative_operator.multicluster | default dict }}
16+
{{- if $mc.enabled }}
17+
{{- $mountPaths := list }}
18+
{{- range ($mc.plugins | default (list)) }}
19+
{{- $mountPaths = append $mountPaths .mountPath }}
20+
{{- end }}
21+
{{- $cfg := $mc.accessProvidersConfig | default dict }}
22+
{{- range ($cfg.providers | default (list)) }}
23+
{{- $cmd := (.execConfig | default dict).command | default "" }}
24+
{{- if $cmd }}
25+
{{- $cmdDir := dir $cmd }}
26+
{{- if not (has $cmdDir $mountPaths) }}
27+
{{- fail (printf "multicluster validation error: provider %q command %q has parent dir %q which does not match any plugins[].mountPath (have %v); execConfig.command parent directory must equal a plugin mountPath" .name $cmd $cmdDir $mountPaths) }}
28+
{{- end }}
29+
{{- end }}
30+
{{- end }}
31+
apiVersion: v1
32+
kind: ConfigMap
33+
metadata:
34+
name: clusterprofile-provider-file
35+
namespace: "{{ .Release.Namespace }}"
36+
labels:
37+
app.kubernetes.io/name: knative-operator
38+
app.kubernetes.io/version: "{{ .Chart.Version }}"
39+
data:
40+
config.json: {{ $mc.accessProvidersConfig | default dict | mustToJson | quote }}
41+
{{- end }}

config/charts/knative-operator/templates/operator.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,5 +855,30 @@ spec:
855855
ports:
856856
- name: metrics
857857
containerPort: 9090
858+
{{- $mc := .Values.knative_operator.multicluster | default dict }}
859+
{{- if $mc.enabled }}
860+
args:
861+
- --clusterprofile-provider-file=/etc/cluster-inventory/config.json
862+
volumeMounts:
863+
- name: cred-config
864+
mountPath: /etc/cluster-inventory
865+
readOnly: true
866+
{{- range ($mc.plugins | default list) }}
867+
- name: {{ .name }}
868+
mountPath: {{ .mountPath }}
869+
readOnly: true
870+
{{- end }}
871+
{{- end }}
872+
{{- if $mc.enabled }}
873+
volumes:
874+
- name: cred-config
875+
configMap:
876+
name: clusterprofile-provider-file
877+
{{- range ($mc.plugins | default list) }}
878+
- name: {{ .name }}
879+
image:
880+
reference: {{ .image }}
881+
{{- end }}
882+
{{- end }}
858883

859884
---

config/charts/knative-operator/templates/rbac/eventing-operator-role.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,3 +401,12 @@ rules:
401401
- list
402402
- get
403403
- watch
404+
# for multicluster support
405+
- apiGroups:
406+
- multicluster.x-k8s.io
407+
resources:
408+
- clusterprofiles
409+
verbs:
410+
- get
411+
- list
412+
- watch

config/charts/knative-operator/templates/rbac/serving-operator-role.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,15 @@ rules:
252252
- pods
253253
verbs:
254254
- get
255+
# for multicluster support
256+
- apiGroups:
257+
- multicluster.x-k8s.io
258+
resources:
259+
- clusterprofiles
260+
verbs:
261+
- get
262+
- list
263+
- watch
255264
# Copyright 2020 The Knative Authors
256265
#
257266
# Licensed under the Apache License, Version 2.0 (the "License");

config/charts/knative-operator/values.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
knative_operator:
2+
# Multi-cluster (Cluster Inventory API): when enabled, the chart mounts
3+
# access provider config and optional plugin images, and sets
4+
# --clusterprofile-provider-file on the operator. ClusterProfile.status
5+
# accessProviders are not managed by this chart.
6+
multicluster:
7+
enabled: false
8+
accessProvidersConfig: {}
9+
# plugins[] uses the Kubernetes "image" volume type
10+
plugins: []
11+
# accessProvidersConfig:
12+
# providers:
13+
# - name: token-secretreader
14+
# execConfig:
15+
# apiVersion: client.authentication.k8s.io/v1
16+
# command: /credential-plugins/token-secretreader/kubeconfig-secretreader-plugin
17+
# provideClusterInfo: true
18+
# plugins:
19+
# - name: token-secretreader
20+
# image: ghcr.io/example/plugin:v1.0.0
21+
# mountPath: /credential-plugins/token-secretreader
222
knative_operator:
323
image: gcr.io/knative-releases/knative.dev/operator/cmd/operator
424
tag: {{ tag }}

config/crd/bases/operator.knative.dev_knativeeventings.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,24 @@ spec:
6666
- URL
6767
type: object
6868
type: array
69+
clusterProfileRef:
70+
description: |-
71+
ClusterProfileRef is an optional reference to a ClusterProfile resource
72+
(multicluster.x-k8s.io/v1alpha1). When set, the operator reconciles
73+
the component on the remote cluster described by the referenced
74+
ClusterProfile instead of the local cluster.
75+
properties:
76+
name:
77+
description: Name is the name of the ClusterProfile resource.
78+
type: string
79+
namespace:
80+
description: Namespace is the namespace of the ClusterProfile
81+
resource.
82+
type: string
83+
required:
84+
- name
85+
- namespace
86+
type: object
6987
config:
7088
additionalProperties:
7189
additionalProperties:

config/crd/bases/operator.knative.dev_knativeservings.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,24 @@ spec:
6666
- URL
6767
type: object
6868
type: array
69+
clusterProfileRef:
70+
description: |-
71+
ClusterProfileRef is an optional reference to a ClusterProfile resource
72+
(multicluster.x-k8s.io/v1alpha1). When set, the operator reconciles
73+
the component on the remote cluster described by the referenced
74+
ClusterProfile instead of the local cluster.
75+
properties:
76+
name:
77+
description: Name is the name of the ClusterProfile resource.
78+
type: string
79+
namespace:
80+
description: Namespace is the namespace of the ClusterProfile
81+
resource.
82+
type: string
83+
required:
84+
- name
85+
- namespace
86+
type: object
6987
config:
7088
additionalProperties:
7189
additionalProperties:

0 commit comments

Comments
 (0)