Skip to content

Commit

Permalink
Update the sample
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 79e5e5c commit baac57a
Show file tree
Hide file tree
Showing 18 changed files with 81 additions and 209 deletions.
4 changes: 0 additions & 4 deletions operator/api/operator/shared/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ import (
// 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.
Expand Down
7 changes: 0 additions & 7 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.

41 changes: 13 additions & 28 deletions operator/api/operator/v1alpha1/multiclusterglobalhubagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,22 @@ import (
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"
// MulticlusterGlobalHubAgent is the Schema for the multiclusterglobalhubagents API
type MulticlusterGlobalHubAgent struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec MulticlusterGlobalHubAgentSpec `json:"spec,omitempty"`
Status MulticlusterGlobalHubAgentStatus `json:"status,omitempty"`
}

// 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 agent image
// +operator-sdk:csv:customresourcedefinitions:type=spec
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:imagePullPolicy"}
Expand All @@ -54,16 +59,9 @@ type MulticlusterGlobalHubAgentSpec struct {
// Compute Resources required by the global hub agent
// +optional
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"`
// TransportConfigSecretName specifies the secret which is used to connect to the global hub Kafka.
// You can get kafka.yaml content using `tools/generate-kafka-config.sh` from the global hub environment.
// Then you can create the secret in the current environment by running `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"`
}
Expand All @@ -74,20 +72,7 @@ type MulticlusterGlobalHubAgentStatus struct {
// Important: Run "make" to regenerate code after modifying this file
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// MulticlusterGlobalHubAgent is the Schema for the multiclusterglobalhubagents API
type MulticlusterGlobalHubAgent struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec MulticlusterGlobalHubAgentSpec `json:"spec,omitempty"`
Status MulticlusterGlobalHubAgentStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// +kubebuilder:object:root=true
// MulticlusterGlobalHubAgentList contains a list of MulticlusterGlobalHubAgent
type MulticlusterGlobalHubAgentList struct {
metav1.TypeMeta `json:",inline"`
Expand Down
8 changes: 0 additions & 8 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.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ metadata:
"metadata": {
"name": "multiclusterglobalhubagent"
},
"spec": {}
"spec": {
"transportConfigSecretName": "transport-config"
}
},
{
"apiVersion": "operator.open-cluster-management.io/v1alpha4",
Expand All @@ -39,7 +41,7 @@ metadata:
categories: Integration & Delivery,OpenShift Optional
certified: "false"
containerImage: quay.io/stolostron/multicluster-global-hub-operator:latest
createdAt: "2024-11-06T07:58:55Z"
createdAt: "2025-01-14T11:53:57Z"
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 @@ -104,9 +106,8 @@ spec:
kind: MulticlusterGlobalHubAgent
name: multiclusterglobalhubagents.operator.open-cluster-management.io
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 agent image'
- description: ImagePullPolicy specifies the pull policy of the multicluster
global hub agent image
displayName: Image Pull Policy
path: imagePullPolicy
x-descriptors:
Expand Down Expand Up @@ -348,13 +349,16 @@ spec:
- ""
resources:
- configmaps
- serviceaccounts
- services
- namespaces
- persistentvolumeclaims
- pods
- secrets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
Expand All @@ -370,21 +374,6 @@ spec:
- patch
- update
- watch
- apiGroups:
- ""
resources:
- namespaces
- persistentvolumeclaims
- pods
- secrets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,21 @@ spec:
kind: MulticlusterGlobalHubAgent
listKind: MulticlusterGlobalHubAgentList
plural: multiclusterglobalhubagents
shortNames:
- mgha
- mcgha
singular: multiclusterglobalhubagent
scope: Namespaced
versions:
- name: v1alpha1
- additionalPrinterColumns:
- description: The overall status of the MulticlusterGlobalHubAgent
jsonPath: .status.phase
name: Status
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
schema:
openAPIV3Schema:
description: MulticlusterGlobalHubAgent is the Schema for the multiclusterglobalhubagents
Expand All @@ -38,16 +49,12 @@ spec:
metadata:
type: object
spec:
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
description: 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 agent image
description: ImagePullPolicy specifies the pull policy of the multicluster
global hub agent image
type: string
imagePullSecret:
description: ImagePullSecret specifies the pull secret of the multicluster
Expand All @@ -61,17 +68,6 @@ spec:
resources:
description: Compute Resources required by the global hub agent
properties:
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: |-
Limits describes the maximum amount of compute resources allowed.
For more information, see: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
requests:
additionalProperties:
anyOf:
Expand Down Expand Up @@ -128,16 +124,9 @@ spec:
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"`
TransportConfigSecretName specifies the secret which is used to connect to the global hub Kafka.
You can get kafka.yaml content using `tools/generate-kafka-config.sh` from the global hub environment.
Then you can create the secret in the current environment by running `kubectl create secret generic transport-config -n "multicluster-global-hub" --from-file=kafka.yaml="./kafka.yaml"`
type: string
type: object
status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,21 @@ spec:
kind: MulticlusterGlobalHubAgent
listKind: MulticlusterGlobalHubAgentList
plural: multiclusterglobalhubagents
shortNames:
- mgha
- mcgha
singular: multiclusterglobalhubagent
scope: Namespaced
versions:
- name: v1alpha1
- additionalPrinterColumns:
- description: The overall status of the MulticlusterGlobalHubAgent
jsonPath: .status.phase
name: Status
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
schema:
openAPIV3Schema:
description: MulticlusterGlobalHubAgent is the Schema for the multiclusterglobalhubagents
Expand All @@ -38,16 +49,12 @@ spec:
metadata:
type: object
spec:
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
description: 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 agent image
description: ImagePullPolicy specifies the pull policy of the multicluster
global hub agent image
type: string
imagePullSecret:
description: ImagePullSecret specifies the pull secret of the multicluster
Expand All @@ -61,17 +68,6 @@ spec:
resources:
description: Compute Resources required by the global hub agent
properties:
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: |-
Limits describes the maximum amount of compute resources allowed.
For more information, see: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
requests:
additionalProperties:
anyOf:
Expand Down Expand Up @@ -128,16 +124,9 @@ spec:
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"`
TransportConfigSecretName specifies the secret which is used to connect to the global hub Kafka.
You can get kafka.yaml content using `tools/generate-kafka-config.sh` from the global hub environment.
Then you can create the secret in the current environment by running `kubectl create secret generic transport-config -n "multicluster-global-hub" --from-file=kafka.yaml="./kafka.yaml"`
type: string
type: object
status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ spec:
kind: MulticlusterGlobalHubAgent
name: multiclusterglobalhubagents.operator.open-cluster-management.io
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 agent image'
- description: ImagePullPolicy specifies the pull policy of the multicluster
global hub agent image
displayName: Image Pull Policy
path: imagePullPolicy
x-descriptors:
Expand Down
22 changes: 5 additions & 17 deletions operator/config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ rules:
- ""
resources:
- configmaps
- serviceaccounts
- services
- namespaces
- persistentvolumeclaims
- pods
- secrets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
Expand All @@ -30,21 +33,6 @@ rules:
- patch
- update
- watch
- apiGroups:
- ""
resources:
- namespaces
- persistentvolumeclaims
- pods
- secrets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
Expand Down
Loading

0 comments on commit baac57a

Please sign in to comment.