Skip to content

Commit

Permalink
Update the instruction
Browse files Browse the repository at this point in the history
Signed-off-by: clyang82 <[email protected]>
  • Loading branch information
clyang82 committed Jan 14, 2025
1 parent db81ba9 commit aa4523f
Show file tree
Hide file tree
Showing 15 changed files with 262 additions and 125 deletions.
40 changes: 40 additions & 0 deletions operator/api/operator/shared/shared.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
Copyright 2024.
Licensed 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.
*/

// Package shared contains API Schema definitions for the operator API group
// +kubebuilder:object:generate=true
// +groupName=operator.open-cluster-management.io

package shared

import (
corev1 "k8s.io/api/core/v1"
)

// ResourceRequirements copied from corev1.ResourceRequirements
// We do not need to support ResourceClaim
type ResourceRequirements struct {
// Limits describes the maximum amount of compute resources allowed.
// For more information, see: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
// +optional
Limits corev1.ResourceList `json:"limits,omitempty"`
// Requests describes the minimum amount of compute resources required.
// If requests are omitted for a container, it defaults to the specified limits.
// If there are no specified limits, it defaults to an implementation-defined value.
// For more information, see: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
// +optional
Requests corev1.ResourceList `json:"requests,omitempty"`
}
54 changes: 54 additions & 0 deletions operator/api/operator/shared/zz_generated.deepcopy.go

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

43 changes: 23 additions & 20 deletions operator/api/operator/v1alpha1/multiclusterglobalhubagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,27 @@ package v1alpha1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

shared "github.com/stolostron/multicluster-global-hub/operator/api/operator/shared"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:shortName={mgha,mcgha}
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.phase",description="The overall status of the MulticlusterGlobalHubAgent"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
// MulticlusterGlobalHubAgentSpec defines the desired state of MulticlusterGlobalHubAgent
type MulticlusterGlobalHubAgentSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
// ImagePullPolicy specifies the pull policy of the multicluster global hub images
// ImagePullPolicy specifies the pull policy of the multicluster global hub agent image
// +operator-sdk:csv:customresourcedefinitions:type=spec
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:imagePullPolicy"}
// +optional
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
// ImagePullSecret specifies the pull secret of the multicluster global hub images
// ImagePullSecret specifies the pull secret of the multicluster global hub agent image
// +operator-sdk:csv:customresourcedefinitions:type=spec
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:io.kubernetes:Secret"}
// +optional
Expand All @@ -45,24 +51,21 @@ type MulticlusterGlobalHubAgentSpec struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec
// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
// Compute Resources required by this component
// +optional
Resources *ResourceRequirements `json:"resources,omitempty"`
}

// ResourceRequirements copied from corev1.ResourceRequirements
// We do not need to support ResourceClaim
type ResourceRequirements struct {
// Limits describes the maximum amount of compute resources allowed.
// For more information, see: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
// +optional
Limits corev1.ResourceList `json:"limits,omitempty"`
// Requests describes the minimum amount of compute resources required.
// If requests are omitted for a container, it defaults to the specified limits.
// If there are no specified limits, it defaults to an implementation-defined value.
// For more information, see: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
// Compute Resources required by the global hub agent
// +optional
Requests corev1.ResourceList `json:"requests,omitempty"`
Resources *shared.ResourceRequirements `json:"resources,omitempty"`
// TransportConfigSecretName specifies the secret which is used to connect to the global hub transport.
// You can fetch the information using the following commands from the global hub environment:
// cat <<EOF >./kafka.yaml
// bootstrap.server: $(kubectl get kafka kafka -n "multicluster-global-hub" -o jsonpath='{.status.listeners[1].bootstrapServers}')
// topic.status: gh-status.global-hub
// ca.crt: $(kubectl get kafka kafka -n "multicluster-global-hub" -o jsonpath='{.status.listeners[1].certificates[0]}' | { if [[ "$OSTYPE" == "darwin"* ]]; then base64 -b 0; else base64 -w 0; fi; })
// client.crt: $(kubectl get secret global-hub-kafka-user -n "multicluster-global-hub" -o jsonpath='{.data.user\.crt}')
// client.key: $(kubectl get secret global-hub-kafka-user -n "multicluster-global-hub" -o jsonpath='{.data.user\.key}')
// EOF
// You can create the secret `kubectl create secret generic transport-config -n "multicluster-global-hub" --from-file=kafka.yaml="./kafka.yaml"`
// +kubebuilder:default=transport-config
TransportConfigSecretName string `json:"transportConfigSecretName,omitempty"`
}

// MulticlusterGlobalHubAgentStatus defines the observed state of MulticlusterGlobalHubAgent
Expand Down
40 changes: 10 additions & 30 deletions operator/api/operator/v1alpha1/zz_generated.deepcopy.go

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

15 changes: 3 additions & 12 deletions operator/api/operator/v1alpha4/multiclusterglobalhub_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package v1alpha4
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

shared "github.com/stolostron/multicluster-global-hub/operator/api/operator/shared"
)

// DataLayerType specifies the type of data layer that global hub stores and transports the data.
Expand Down Expand Up @@ -141,18 +143,7 @@ type AdvancedSpec struct {
type CommonSpec struct {
// Compute Resources required by this component
// +optional
Resources *ResourceRequirements `json:"resources,omitempty"`
}

// ResourceRequirements copied from corev1.ResourceRequirements
// We do not need to support ResourceClaim
type ResourceRequirements struct {
// Requests describes the minimum amount of compute resources required.
// If requests are omitted for a container, it defaults to the specified limits.
// If there are no specified limits, it defaults to an implementation-defined value.
// For more information, see: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
// +optional
Requests corev1.ResourceList `json:"requests,omitempty"`
Resources *shared.ResourceRequirements `json:"resources,omitempty"`
}

// DataLayerSpec is a discriminated union of data layer specific configuration.
Expand Down
25 changes: 2 additions & 23 deletions operator/api/operator/v1alpha4/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ metadata:
categories: Integration & Delivery,OpenShift Optional
certified: "false"
containerImage: quay.io/stolostron/multicluster-global-hub-operator:latest
createdAt: "2024-11-05T14:24:34Z"
createdAt: "2024-11-06T07:58:55Z"
description: Manages the installation and upgrade of the Multicluster Global Hub.
features.operators.openshift.io/cnf: "false"
features.operators.openshift.io/cni: "false"
Expand Down Expand Up @@ -106,13 +106,13 @@ spec:
specDescriptors:
- description: 'INSERT ADDITIONAL SPEC FIELDS - desired state of cluster Important:
Run "make" to regenerate code after modifying this file ImagePullPolicy
specifies the pull policy of the multicluster global hub images'
specifies the pull policy of the multicluster global hub agent image'
displayName: Image Pull Policy
path: imagePullPolicy
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:imagePullPolicy
- description: ImagePullSecret specifies the pull secret of the multicluster
global hub images
global hub agent image
displayName: Image Pull Secret
path: imagePullSecret
x-descriptors:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,28 @@ spec:
metadata:
type: object
spec:
description: MulticlusterGlobalHubAgentSpec defines the desired state
of MulticlusterGlobalHubAgent
description: |-
EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
MulticlusterGlobalHubAgentSpec defines the desired state of MulticlusterGlobalHubAgent
properties:
imagePullPolicy:
description: |-
INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
Important: Run "make" to regenerate code after modifying this file
ImagePullPolicy specifies the pull policy of the multicluster global hub images
ImagePullPolicy specifies the pull policy of the multicluster global hub agent image
type: string
imagePullSecret:
description: ImagePullSecret specifies the pull secret of the multicluster
global hub images
global hub agent image
type: string
nodeSelector:
additionalProperties:
type: string
description: NodeSelector specifies the desired state of NodeSelector
type: object
resources:
description: Compute Resources required by this component
description: Compute Resources required by the global hub agent
properties:
limits:
additionalProperties:
Expand Down Expand Up @@ -123,6 +125,20 @@ spec:
type: string
type: object
type: array
transportConfigSecretName:
default: transport-config
description: |-
TransportConfigSecretName specifies the secret which is used to connect to the global hub transport.
You can fetch the information using the following commands from the global hub environment:
cat <<EOF >./kafka.yaml
bootstrap.server: $(kubectl get kafka kafka -n "multicluster-global-hub" -o jsonpath='{.status.listeners[1].bootstrapServers}')
topic.status: gh-status.global-hub
ca.crt: $(kubectl get kafka kafka -n "multicluster-global-hub" -o jsonpath='{.status.listeners[1].certificates[0]}' | { if [[ "$OSTYPE" == "darwin"* ]]; then base64 -b 0; else base64 -w 0; fi; })
client.crt: $(kubectl get secret global-hub-kafka-user -n "multicluster-global-hub" -o jsonpath='{.data.user\.crt}')
client.key: $(kubectl get secret global-hub-kafka-user -n "multicluster-global-hub" -o jsonpath='{.data.user\.key}')
EOF
You can create the secret `kubectl create secret generic transport-config -n "multicluster-global-hub" --from-file=kafka.yaml="./kafka.yaml"`
type: string
type: object
status:
description: MulticlusterGlobalHubAgentStatus defines the observed state
Expand Down
Loading

0 comments on commit aa4523f

Please sign in to comment.