Skip to content

Commit

Permalink
Auto detect spoke externalServerURLs
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Nov 14, 2023
1 parent d501c39 commit 1b8f429
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 39 deletions.
11 changes: 0 additions & 11 deletions apis/installer/v1alpha1/cluster_manager_spoke_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ type ClusterManagerSpokeSpec struct {
// +optional
Hub SpokeHub `json:"hub"`

// Klusterlet is the klusterlet related configuration
// +optional
Klusterlet Klusterlet `json:"klusterlet"`

// Registry is the image registry related configuration
// +optional
Registry string `json:"registry"`
Expand Down Expand Up @@ -83,13 +79,6 @@ type SpokeHub struct {
KubeConfig string `json:"kubeConfig"`
}

// Klusterlet is for templating klusterlet configuration
type Klusterlet struct {
// APIServer: The API Server external URL
// +optional
APIServer string `json:"apiServer"`
}

type SpokeBundleVersion struct {
// registration image version
// +optional
Expand Down
16 changes: 0 additions & 16 deletions apis/installer/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion charts/cluster-manager-spoke/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ The following table lists the configurable parameters of the `cluster-manager-sp
| clusterName | | <code>""</code> |
| hub.apiServer | | <code>""</code> |
| hub.kubeConfig | | <code>""</code> |
| klusterlet.apiServer | | <code>""</code> |
| registry | | <code>quay.io/open-cluster-management</code> |
| bundleVersion.registrationImageVersion | | <code>""</code> |
| bundleVersion.placementImageVersion | | <code>""</code> |
Expand Down
15 changes: 12 additions & 3 deletions charts/cluster-manager-spoke/templates/klusterlets.cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ data:

---

# Test using:
# helm install cluster-manager-spoke charts/cluster-manager-spoke --set hub.kubeConfig=abc --set clusterName=abc --dry-run=server

{{- $spokeConfig := (lookup "v1" "ConfigMap" "kube-public" "cluster-info").data.kubeconfig | fromYaml -}}
{{- $spokeServer := (dig "cluster" "server" "" (first $spokeConfig.clusters)) -}}
{{- if not (or (hasPrefix "http://" $spokeServer) (hasPrefix "https://" $spokeServer)) }}
{{- $spokeServer = "" }}
{{- end }}

apiVersion: operator.open-cluster-management.io/v1
kind: Klusterlet
metadata:
Expand All @@ -57,10 +66,10 @@ spec:
imagePullSpec: {{ .Values.registry}}/registration-operator:{{ default .Chart.AppVersion .Values.bundleVersion.operatorImageVersion}}
clusterName: {{ required "A valid clusterName entry required!" .Values.clusterName }}
namespace: {{ $klusterletNamespace }}
{{- if $spokeServer }}
externalServerURLs:
{{ if .Values.klusterlet.apiServer }}
- url: {{ .Values.klusterlet.apiServer }}
{{ end }}
- url: {{ $spokeServer }}
{{- end }}
{{if .Values.registrationFeatures}}
registrationConfiguration:
featureGates:
Expand Down
5 changes: 0 additions & 5 deletions charts/cluster-manager-spoke/values.openapiv3_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ properties:
kubeConfig:
type: string
type: object
klusterlet:
properties:
apiServer:
type: string
type: object
managedKubeconfig:
type: string
registrationFeatures:
Expand Down
3 changes: 0 additions & 3 deletions charts/cluster-manager-spoke/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ hub:
apiServer: ""
kubeConfig: ""

klusterlet:
apiServer: ""

registry: quay.io/open-cluster-management

bundleVersion:
Expand Down

0 comments on commit 1b8f429

Please sign in to comment.