Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Deploy agent via global hub operator #1202

Merged
merged 9 commits into from
Jan 16, 2025
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
9 changes: 9 additions & 0 deletions operator/PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,13 @@ resources:
kind: ManagedClusterMigration
path: github.com/stolostron/multicluster-global-hub-operator/migration/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: open-cluster-management.io
group: operator
kind: MulticlusterGlobalHubAgent
path: github.com/stolostron/multicluster-global-hub-operator/api/operator/v1alpha1
version: v1alpha1
version: "3"
36 changes: 36 additions & 0 deletions operator/api/operator/shared/shared.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
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 {
// 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"`
}
47 changes: 47 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.

36 changes: 36 additions & 0 deletions operator/api/operator/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright 2022.

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 v1alpha1 contains API Schema definitions for the operator v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=operator.open-cluster-management.io
package v1alpha1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "operator.open-cluster-management.io", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
85 changes: 85 additions & 0 deletions operator/api/operator/v1alpha1/multiclusterglobalhubagent_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
Copyright 2022.

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 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"
)

// +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 {
// 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 agent image
// +operator-sdk:csv:customresourcedefinitions:type=spec
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:io.kubernetes:Secret"}
// +optional
ImagePullSecret string `json:"imagePullSecret,omitempty"`
// NodeSelector specifies the desired state of NodeSelector
// +optional
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
// Tolerations causes all components to tolerate any taints
// +operator-sdk:csv:customresourcedefinitions:type=spec
// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
// 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 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"`
}

// MulticlusterGlobalHubAgentStatus defines the observed state of MulticlusterGlobalHubAgent
type MulticlusterGlobalHubAgentStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}

// +kubebuilder:object:root=true
// MulticlusterGlobalHubAgentList contains a list of MulticlusterGlobalHubAgent
type MulticlusterGlobalHubAgentList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []MulticlusterGlobalHubAgent `json:"items"`
}

func init() {
SchemeBuilder.Register(&MulticlusterGlobalHubAgent{}, &MulticlusterGlobalHubAgentList{})
}
136 changes: 136 additions & 0 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
Loading
Loading