diff --git a/cmd/clusterlifecycle-state-metrics/main.go b/cmd/clusterlifecycle-state-metrics/main.go index 83b56f19..19451ad7 100644 --- a/cmd/clusterlifecycle-state-metrics/main.go +++ b/cmd/clusterlifecycle-state-metrics/main.go @@ -122,7 +122,7 @@ func start(opts *options.Options) { klog.Fatal(err) } - klog.Infof("metric white- blacklisting: %v", whiteBlackList.Status()) + klog.Infof("metric white-black listing: %v", whiteBlackList.Status()) collectorBuilder.WithWhiteBlackList(whiteBlackList) diff --git a/pkg/collectors/builder.go b/pkg/collectors/builder.go index 897c76b9..3e4adcee 100644 --- a/pkg/collectors/builder.go +++ b/pkg/collectors/builder.go @@ -4,6 +4,8 @@ package collectors import ( + "fmt" + "os" "sort" "strings" "time" @@ -36,6 +38,10 @@ import ( "github.com/stolostron/clusterlifecycle-state-metrics/pkg/generators/work" ) +const ( + configMapName = "clusterlifecycle-state-metrics-config" +) + var ResyncPeriod = 60 * time.Minute type whiteBlackLister interface { @@ -54,22 +60,28 @@ type Builder struct { enabledCollectors []string whiteBlackList whiteBlackLister restConfig *rest.Config + kubeclient kubernetes.Interface clusterIdCache *clusterIdCache + clusterTimestampCache *clusterTimestampCache composedClusterStore *composedStore composedAddOnStore *composedStore composedManifestWorkStore *composedStore + + timestampMetricsEnabled bool } // NewBuilder returns a new builder. func NewBuilder(ctx context.Context) *Builder { clusterIdCache := newClusterIdCache() + clusterTimestampCache := newClusterTimestampCache() return &Builder{ ctx: ctx, clusterIdCache: clusterIdCache, + clusterTimestampCache: clusterTimestampCache, composedClusterStore: newComposedStore(clusterIdCache), composedAddOnStore: newComposedStore(), - composedManifestWorkStore: newComposedStore(), + composedManifestWorkStore: newComposedStore(clusterTimestampCache), } } @@ -123,6 +135,18 @@ func (b *Builder) Build() []MetricsCollector { } b.restConfig = config + kubeClient, err := kubernetes.NewForConfig(b.restConfig) + if err != nil { + klog.Fatalf("cannot create kubeClient: %v", err) + } + b.kubeclient = kubeClient + + timestampMetricsEnabled, err := isTimestampMetricsEnabled(kubeClient) + if err != nil { + klog.Fatalf("cannot determine if timestamp metrics should be enabled: %v", err) + } + b.timestampMetricsEnabled = timestampMetricsEnabled + collectors := []MetricsCollector{} activeCollectorNames := []string{} @@ -161,20 +185,19 @@ func (b *Builder) buildManagedClusterCollector() MetricsCollector { klog.Fatalf("cannot create ocpclient: %v", err) } - kubeClient, err := kubernetes.NewForConfig(b.restConfig) - if err != nil { - klog.Fatalf("cannot create kubeClient: %v", err) - } - - hubClusterID := getHubClusterID(ocpClient, kubeClient) + hubClusterID := getHubClusterID(ocpClient, b.kubeclient) - filteredMetricFamilies := metric.FilterMetricFamilies(b.whiteBlackList, - []metric.FamilyGenerator{ - cluster.GetManagedClusterInfoMetricFamilies(hubClusterID, b.hubType), - cluster.GetManagedClusterLabelMetricFamilies(hubClusterID), - cluster.GetManagedClusterStatusMetricFamilies(), - cluster.GetManagedClusterWorkerCoresMetricFamilies(hubClusterID), - }) + clusterFamilies := []metric.FamilyGenerator{ + cluster.GetManagedClusterInfoMetricFamilies(hubClusterID, b.hubType), + cluster.GetManagedClusterLabelMetricFamilies(hubClusterID), + cluster.GetManagedClusterStatusMetricFamilies(), + cluster.GetManagedClusterWorkerCoresMetricFamilies(hubClusterID), + } + if b.timestampMetricsEnabled { + clusterFamilies = append(clusterFamilies, + cluster.GetManagedClusterTimestampMetricFamilies(hubClusterID, b.clusterTimestampCache.GetClusterTimestamps)) + } + filteredMetricFamilies := metric.FilterMetricFamilies(b.whiteBlackList, clusterFamilies) composedMetricGenFuncs := metric.ComposeMetricGenFuncs(filteredMetricFamilies) familyHeaders := metric.ExtractMetricFamilyHeaders(filteredMetricFamilies) metricsStore := metricsstore.NewMetricsStore( @@ -221,10 +244,13 @@ func (b *Builder) buildManagedClusterAddOnCollector() MetricsCollector { func (b *Builder) buildManifestWorkCollector() MetricsCollector { // build metrics store - filteredMetricFamilies := metric.FilterMetricFamilies(b.whiteBlackList, - []metric.FamilyGenerator{ - work.GetManifestWorkStatusMetricFamilies(b.clusterIdCache.GetClusterId), - }) + workFamilies := []metric.FamilyGenerator{ + work.GetManifestWorkStatusMetricFamilies(b.clusterIdCache.GetClusterId), + } + if b.timestampMetricsEnabled { + workFamilies = append(workFamilies, work.GetManifestWorkTimestampMetricFamilies(b.clusterIdCache.GetClusterId)) + } + filteredMetricFamilies := metric.FilterMetricFamilies(b.whiteBlackList, workFamilies) composedMetricGenFuncs := metric.ComposeMetricGenFuncs(filteredMetricFamilies) familyHeaders := metric.ExtractMetricFamilyHeaders(filteredMetricFamilies) metricsStore := metricsstore.NewMetricsStore( @@ -274,6 +300,17 @@ func (b *Builder) startWatchingManagedClusters() { } klog.Infof("Cluster ID cached for %d managed clusters", len(clusters)) + // refresh the managed cluster store once the timestamp of a certian cluster is changed + b.clusterTimestampCache.AddOnTimestampChangeFunc(func(clusterName string) error { + klog.Infof("Refresh the managed cluster metrics since the timestamp of cluster %q is changed", clusterName) + cluster, err := clusterClient.ClusterV1().ManagedClusters().Get(b.ctx, clusterName, metav1.GetOptions{}) + if err != nil { + return err + } + + return b.composedClusterStore.Update(cluster) + }) + // start watching managed clusters lw := cache.NewListWatchFromClient(clusterClient.ClusterV1().RESTClient(), "managedclusters", metav1.NamespaceAll, fields.Everything()) reflector := cache.NewReflector(lw, &mcv1.ManagedCluster{}, b.composedClusterStore, ResyncPeriod) @@ -370,3 +407,35 @@ func getHubClusterID(ocpClient ocpclient.Interface, kubeClient kubernetes.Interf klog.Fatalf("Error getting cluster version %v \n,", err) return "" } + +// Check the ConfigMap to see if the timestamp-metrics should be enabled +func isTimestampMetricsEnabled(clientset *kubernetes.Clientset) (bool, error) { + namespace, err := GetComponentNamespace() + if err != nil { + return false, fmt.Errorf("failed to get namespace: %v", err) + } + + // Get the ConfigMap + cm, err := clientset.CoreV1().ConfigMaps(namespace).Get(context.TODO(), configMapName, metav1.GetOptions{}) + if errors.IsNotFound(err) { + return false, nil + } else if err != nil { + return false, fmt.Errorf("failed to get ConfigMap: %v", err) + } + + // Check if collect-timestamp-metrics is "enable" + value, exists := cm.Data["collect-timestamp-metrics"] + if !exists { + return false, nil + } + + return value == "Enable", nil +} + +func GetComponentNamespace() (string, error) { + nsBytes, err := os.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace") + if err != nil { + return "multicluster-engine", err + } + return string(nsBytes), nil +} diff --git a/pkg/collectors/clustertimestampcache.go b/pkg/collectors/clustertimestampcache.go new file mode 100644 index 00000000..803ec74a --- /dev/null +++ b/pkg/collectors/clustertimestampcache.go @@ -0,0 +1,223 @@ +// Copyright (c) 2020 Red Hat, Inc. +// Copyright Contributors to the Open Cluster Management project + +package collectors + +import ( + "fmt" + "reflect" + "strings" + "sync" + "time" + + "k8s.io/apimachinery/pkg/api/meta" + utilerrors "k8s.io/apimachinery/pkg/util/errors" + "k8s.io/klog/v2" + operatorv1 "open-cluster-management.io/api/operator/v1" + workv1 "open-cluster-management.io/api/work/v1" +) + +const ( + HostedClusterLabel = "import.open-cluster-management.io/hosted-cluster" + StatusManagedClusterKubeconfigProvided = "ManagedClusterKubeconfigProvided" + StatusStartToApplyKlusterletResources = "StartToApplyKlusterletResources" +) + +type onTimestampChangeFunc func(clusterName string) error + +// clusterTimestampCache implements the k8s.io/client-go/tools/cache.Store interface. +// It stores timestamps for the cluster importing phases of ManagedCluster objects. +// Note the cached value is for ManagedCluster, but the input obj should be a ManifestWork. +type clusterTimestampCache struct { + // Protects metrics + mutex sync.RWMutex + + // data is a map indexed by cluster name with timestamps of different status + data map[string]map[string]float64 + + onTimestampChangeFuncs []onTimestampChangeFunc +} + +func newClusterTimestampCache() *clusterTimestampCache { + return &clusterTimestampCache{ + data: map[string]map[string]float64{}, + } +} + +func (s *clusterTimestampCache) GetClusterTimestamps(clusterName string) map[string]float64 { + return s.data[clusterName] +} + +// Add implements the Add method of the store interface. +func (s *clusterTimestampCache) Add(obj interface{}) error { + mw, ok := obj.(*workv1.ManifestWork) + if !ok { + return fmt.Errorf("invalid ManifestWork: %v", obj) + } + + clusterName, ok := mw.GetLabels()[HostedClusterLabel] + if !ok { + return nil + } + + s.mutex.Lock() + defer s.mutex.Unlock() + + newTimestamps, err := getClusterTimestamps(clusterName, mw.Status) + if err != nil { + return err + } + + timestamps := s.data[clusterName] + if reflect.DeepEqual(newTimestamps, timestamps) { + return nil + } + + s.data[clusterName] = newTimestamps + klog.V(5).Infof("Timestamps of cluster %q is changed from %v to %v", clusterName, timestamps, newTimestamps) + + // run callback funcs once cluster ID is changed + errs := []error{} + for _, callback := range s.onTimestampChangeFuncs { + if err := callback(clusterName); err != nil { + errs = append(errs, err) + } + } + return utilerrors.NewAggregate(errs) +} + +func getClusterTimestamps(clusterName string, workStatus workv1.ManifestWorkStatus) (map[string]float64, error) { + for _, manifest := range workStatus.ResourceStatus.Manifests { + if manifest.ResourceMeta.Group != operatorv1.GroupName || + (manifest.ResourceMeta.Kind != "Klusterlet" && manifest.ResourceMeta.Resource != "klusterlets") || + manifest.ResourceMeta.Name != hostedKlusterletCRName(clusterName) { + continue + } + + return getClusterTimestampsByFeedbackRules(manifest.StatusFeedbacks.Values) + } + + return nil, nil +} + +func getClusterTimestampsByFeedbackRules(feedbackValues []workv1.FeedbackValue) (map[string]float64, error) { + var status bool = false + var message, lastTransitionTime string + for _, fb := range feedbackValues { + if fb.Name == "ReadyToApply-status" && fb.Value.String != nil { + status = strings.EqualFold(*fb.Value.String, "True") + } + if fb.Name == "ReadyToApply-message" && fb.Value.String != nil { + message = *fb.Value.String + } + if fb.Name == "ReadyToApply-lastTransitionTime" && fb.Value.String != nil { + lastTransitionTime = *fb.Value.String + } + } + + if !status { + return nil, nil + } + + timestamps := make(map[string]float64) + transition, err := time.Parse(time.RFC3339, lastTransitionTime) + if err != nil { + return nil, fmt.Errorf("failed to parse last transition time %q: %v", lastTransitionTime, err) + } + timestamps[StatusStartToApplyKlusterletResources] = float64(transition.Unix()) + + // parse the message to get the kubeconfig secret creation time, the message format is: + // "Klusterlet is ready to apply, the external managed kubeconfig secret was created at: 2021-07-01T00:00:00Z" + parts := strings.SplitN(message, "the external managed kubeconfig secret was created at:", 2) + if len(parts) == 2 { + creationTime, err := time.Parse(time.RFC3339, strings.TrimSpace(parts[1])) + if err != nil { + return nil, fmt.Errorf("failed to parse kubeconfig secret creation time %q: %v", parts[1], err) + } + timestamps[StatusManagedClusterKubeconfigProvided] = float64(creationTime.Unix()) + } + return timestamps, nil +} + +func hostedKlusterletCRName(managedClusterName string) string { + return fmt.Sprintf("klusterlet-%s", managedClusterName) +} + +// Update implements the Update method of the store interface. +func (s *clusterTimestampCache) Update(obj interface{}) error { + return s.Add(obj) +} + +// Delete implements the Delete method of the store interface. +func (s *clusterTimestampCache) Delete(obj interface{}) error { + mw, err := meta.Accessor(obj) + if err != nil { + return err + } + clusterName, ok := mw.GetLabels()[HostedClusterLabel] + if !ok { + return nil + } + + s.mutex.Lock() + defer s.mutex.Unlock() + + delete(s.data, clusterName) + return nil +} + +// List implements the List method of the store interface. +func (s *clusterTimestampCache) List() []interface{} { + return nil +} + +// ListKeys implements the ListKeys method of the store interface. +func (s *clusterTimestampCache) ListKeys() []string { + return nil +} + +// Get implements the Get method of the store interface. +func (s *clusterTimestampCache) Get(obj interface{}) (item interface{}, exists bool, err error) { + return nil, false, nil +} + +// GetByKey implements the GetByKey method of the store interface. +func (s *clusterTimestampCache) GetByKey(key string) (item interface{}, exists bool, err error) { + timestamps, ok := s.data[key] + return timestamps, ok, nil +} + +// Replace implements the Replace method of the store interface. +func (s *clusterTimestampCache) Replace(list []interface{}, _ string) error { + s.mutex.Lock() + defer s.mutex.Unlock() + + s.data = map[string]map[string]float64{} + + for _, obj := range list { + mw, ok := obj.(*workv1.ManifestWork) + if !ok { + return fmt.Errorf("invalid ManifestWork: %v", obj) + } + clusterName, ok := mw.GetLabels()[HostedClusterLabel] + if !ok { + return nil + } + timestamps, err := getClusterTimestamps(clusterName, mw.Status) + if err != nil { + return err + } + s.data[clusterName] = timestamps + } + + return nil +} + +// Resync implements the Resync method of the store interface. +func (s *clusterTimestampCache) Resync() error { + return nil +} + +func (s *clusterTimestampCache) AddOnTimestampChangeFunc(callback onTimestampChangeFunc) { + s.onTimestampChangeFuncs = append(s.onTimestampChangeFuncs, callback) +} diff --git a/pkg/collectors/clustertimestampcache_test.go b/pkg/collectors/clustertimestampcache_test.go new file mode 100644 index 00000000..0740a38b --- /dev/null +++ b/pkg/collectors/clustertimestampcache_test.go @@ -0,0 +1,230 @@ +// Copyright (c) 2020 Red Hat, Inc. +// Copyright Contributors to the Open Cluster Management project + +package collectors + +import ( + "reflect" + "testing" + "time" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + operatorv1 "open-cluster-management.io/api/operator/v1" + workv1 "open-cluster-management.io/api/work/v1" +) + +func Test_ClusterTimestampCache(t *testing.T) { + t1, err := time.Parse(time.RFC3339, "2021-09-01T00:01:01Z") + if err != nil { + t.Errorf("unexpected error: %v", err) + } + t2, err := time.Parse(time.RFC3339, "2021-09-01T00:01:02Z") + if err != nil { + t.Errorf("unexpected error: %v", err) + } + work1 := &workv1.ManifestWork{ + ObjectMeta: metav1.ObjectMeta{ + Name: "cluster1-hosted-klusterlet", + Namespace: "local-cluster", + Labels: map[string]string{ + HostedClusterLabel: "cluster1", + }, + }, + Status: workv1.ManifestWorkStatus{ + ResourceStatus: workv1.ManifestResourceStatus{ + Manifests: []workv1.ManifestCondition{ + { + ResourceMeta: workv1.ManifestResourceMeta{ + Group: operatorv1.GroupName, + Kind: "Klusterlet", + Resource: "klusterlets", + Name: "klusterlet-cluster1", + }, + StatusFeedbacks: workv1.StatusFeedbackResult{ + Values: []workv1.FeedbackValue{ + { + Name: "ReadyToApply-status", + Value: workv1.FieldValue{ + String: &[]string{"True"}[0], + }, + }, + { + Name: "ReadyToApply-lastTransitionTime", + Value: workv1.FieldValue{ + String: &[]string{"2021-09-01T00:01:02Z"}[0], + }, + }, + { + Name: "ReadyToApply-message", + Value: workv1.FieldValue{ + String: &[]string{"Klusterlet is ready to apply, the external managed kubeconfig secret was created at: 2021-09-01T00:01:01Z"}[0], + }, + }, + }, + }, + }, + }, + }, + }, + } + + work1Modified := work1.DeepCopy() + work1Modified.Status.ResourceStatus.Manifests[0].StatusFeedbacks.Values[1].Value.String = &[]string{"2021-09-01T00:01:01Z"}[0] + work1ModifiedNull := work1.DeepCopy() + work1ModifiedNull.Status.ResourceStatus.Manifests[0].StatusFeedbacks.Values[0].Value.String = &[]string{"False"}[0] + + work2 := &workv1.ManifestWork{ + ObjectMeta: metav1.ObjectMeta{ + Name: "cluster2-hosted-klusterlet", + Namespace: "local-cluster", + Labels: map[string]string{ + HostedClusterLabel: "cluster2", + }, + }, + Status: workv1.ManifestWorkStatus{ + ResourceStatus: workv1.ManifestResourceStatus{ + Manifests: []workv1.ManifestCondition{ + { + ResourceMeta: workv1.ManifestResourceMeta{ + Group: operatorv1.GroupName, + Kind: "Klusterlet", + Resource: "klusterlets", + Name: "klusterlet-cluster2", + }, + StatusFeedbacks: workv1.StatusFeedbackResult{ + Values: []workv1.FeedbackValue{ + { + Name: "ReadyToApply-status", + Value: workv1.FieldValue{ + String: &[]string{"True"}[0], + }, + }, + { + Name: "ReadyToApply-lastTransitionTime", + Value: workv1.FieldValue{ + String: &[]string{"2021-09-01T00:01:02Z"}[0], + }, + }, + { + Name: "ReadyToApply-message", + Value: workv1.FieldValue{ + String: &[]string{"Klusterlet is ready to apply, the external managed kubeconfig secret was created at: 2021-09-01T00:01:02Z"}[0], + }, + }, + }, + }, + }, + }, + }, + }, + } + + tests := []struct { + name string + clusterName string + existing []interface{} + toAdd []interface{} + toUpdate []interface{} + toDelete []interface{} + want map[string]float64 + numberOfTimestampChanged int + }{ + { + name: "empty", + clusterName: "cluster1", + want: nil, + }, + { + name: "existing", + clusterName: "cluster1", + existing: []interface{}{work1}, + want: map[string]float64{ + StatusManagedClusterKubeconfigProvided: float64(t1.Unix()), + StatusStartToApplyKlusterletResources: float64(t2.Unix()), + }, + }, + { + name: "add", + clusterName: "cluster1", + toAdd: []interface{}{work1}, + want: map[string]float64{ + StatusManagedClusterKubeconfigProvided: float64(t1.Unix()), + StatusStartToApplyKlusterletResources: float64(t2.Unix()), + }, + numberOfTimestampChanged: 1, + }, + { + name: "update cluster1", + clusterName: "cluster1", + existing: []interface{}{work1}, + toUpdate: []interface{}{work1Modified}, + want: map[string]float64{ + StatusManagedClusterKubeconfigProvided: float64(t1.Unix()), + StatusStartToApplyKlusterletResources: float64(t1.Unix()), + }, + numberOfTimestampChanged: 1, + }, + { + name: "update cluster1 to null", + clusterName: "cluster1", + existing: []interface{}{work1}, + toUpdate: []interface{}{work1ModifiedNull}, + want: nil, + numberOfTimestampChanged: 1, + }, + { + name: "update cluster2", + clusterName: "cluster2", + toAdd: []interface{}{work1}, + toUpdate: []interface{}{work2}, + want: map[string]float64{ + StatusManagedClusterKubeconfigProvided: float64(t2.Unix()), + StatusStartToApplyKlusterletResources: float64(t2.Unix()), + }, + numberOfTimestampChanged: 2, + }, + { + name: "delete", + clusterName: "cluster1", + existing: []interface{}{work1}, + toDelete: []interface{}{work1}, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + numberOfTimestampChanged := 0 + cache := newClusterTimestampCache() + cache.AddOnTimestampChangeFunc(func(clusterName string) error { + numberOfTimestampChanged += 1 + return nil + }) + + err := cache.Replace(tt.existing, "") + if err != nil { + t.Errorf("caught unexpected err: %c", err) + } + + for _, obj := range tt.toAdd { + cache.Add(obj) + } + + for _, obj := range tt.toUpdate { + cache.Update(obj) + } + + for _, obj := range tt.toDelete { + cache.Delete(obj) + } + + if actual := cache.GetClusterTimestamps(tt.clusterName); !reflect.DeepEqual(actual, tt.want) { + t.Errorf("want\n%v\nbut got\n%v", tt.want, actual) + } + + if numberOfTimestampChanged != tt.numberOfTimestampChanged { + t.Errorf("want numberOfTimestampChanged %d\nbut got%d", + tt.numberOfTimestampChanged, numberOfTimestampChanged) + } + }) + } +} diff --git a/pkg/generators/cluster/managedclustertimestamp.go b/pkg/generators/cluster/managedclustertimestamp.go new file mode 100644 index 00000000..0a91edbf --- /dev/null +++ b/pkg/generators/cluster/managedclustertimestamp.go @@ -0,0 +1,97 @@ +// Copyright (c) 2020 Red Hat, Inc. +// Copyright Contributors to the Open Cluster Management project + +package cluster + +import ( + "github.com/stolostron/clusterlifecycle-state-metrics/pkg/generators" + "k8s.io/apimachinery/pkg/api/meta" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/klog/v2" + "k8s.io/kube-state-metrics/pkg/metric" + mcv1 "open-cluster-management.io/api/cluster/v1" +) + +var ( + descTimestampName = "acm_managed_cluster_import_timestamp" + descTimestampHelp = "The timestamp of different status when importing an ACM managed clusters" + hostingClusterNameAnnotation string = "import.open-cluster-management.io/hosting-cluster-name" +) + +func GetManagedClusterTimestampMetricFamilies(hubClusterID string, + getClusterTimestamps func(clusterName string) map[string]float64) metric.FamilyGenerator { + return metric.FamilyGenerator{ + Name: descTimestampName, + Type: metric.Gauge, + Help: descTimestampHelp, + GenerateFunc: wrapManagedClusterTimestampFunc(func(mc *mcv1.ManagedCluster) metric.Family { + klog.Infof("Wrap %s", mc.GetName()) + keys := []string{"managed_cluster_name"} + values := []string{mc.GetName()} + if clusterId := getClusterID(mc); len(clusterId) > 0 { + keys = append(keys, "managed_cluster_id") + values = append(values, clusterId) + } + if hostingcluster, ok := mc.GetAnnotations()[hostingClusterNameAnnotation]; ok { + keys = append(keys, "hosting_cluster_name") + values = append(values, hostingcluster) + } + + f := buildManagedClusterTimestampMetricFamily( + mc, + keys, + values, + getClusterTimestamps, + ) + klog.Infof("Returning %v", string(f.ByteSlice())) + return f + }), + } +} + +func wrapManagedClusterTimestampFunc(f func(obj *mcv1.ManagedCluster) metric.Family) func(interface{}) *metric.Family { + return func(obj interface{}) *metric.Family { + cluster := obj.(*mcv1.ManagedCluster) + + metricFamily := f(cluster) + + for _, m := range metricFamily.Metrics { + m.LabelKeys = append([]string{}, m.LabelKeys...) + m.LabelValues = append([]string{}, m.LabelValues...) + } + + return &metricFamily + } +} + +func buildManagedClusterTimestampMetricFamily(mc *mcv1.ManagedCluster, labelKeys, labelValues []string, + getClusterTimestamps func(clusterName string) map[string]float64) metric.Family { + family := metric.Family{} + + family.Metrics = append(family.Metrics, + generators.BuildTimestampMetric(mc.CreationTimestamp, labelKeys, labelValues, generators.CreatedTimestamp)) + + // handle existing conditions + joinedCond := meta.FindStatusCondition(mc.Status.Conditions, mcv1.ManagedClusterConditionJoined) + if joinedCond != nil && joinedCond.Status == metav1.ConditionTrue { + family.Metrics = append(family.Metrics, generators.BuildTimestampMetric( + joinedCond.LastTransitionTime, labelKeys, labelValues, generators.JoinedTimestamp)) + } + + timestamps := getClusterTimestamps(mc.GetName()) + if len(timestamps) == 0 { + return family + } + + for status, timestamp := range timestamps { + family.Metrics = append(family.Metrics, + &metric.Metric{ + // do not use 'LabelValues: append(labelValues, status),', + // prevent from using the shared backing array + LabelKeys: append([]string{"status"}, labelKeys...), + LabelValues: append([]string{status}, labelValues...), + Value: timestamp, + }) + } + return family +} diff --git a/pkg/generators/cluster/managedclustertimestamp_test.go b/pkg/generators/cluster/managedclustertimestamp_test.go new file mode 100644 index 00000000..eeb406b4 --- /dev/null +++ b/pkg/generators/cluster/managedclustertimestamp_test.go @@ -0,0 +1,91 @@ +// Copyright (c) 2020 Red Hat, Inc. +// Copyright Contributors to the Open Cluster Management project + +package cluster + +import ( + "fmt" + "testing" + "time" + + testcommon "github.com/stolostron/clusterlifecycle-state-metrics/test/unit/common" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/kube-state-metrics/pkg/metric" + mcv1 "open-cluster-management.io/api/cluster/v1" +) + +func Test_getManagedClusterTimestampMetricFamilies(t *testing.T) { + t1, err := time.Parse(time.RFC3339, "2021-09-01T00:01:01Z") + if err != nil { + t.Errorf("unexpected error: %v", err) + } + t2, err := time.Parse(time.RFC3339, "2021-09-01T00:01:02Z") + if err != nil { + t.Errorf("unexpected error: %v", err) + } + + mc := &mcv1.ManagedCluster{ + ObjectMeta: metav1.ObjectMeta{ + Name: "cluster1", + CreationTimestamp: metav1.Time{Time: t1}, + Annotations: map[string]string{ + "import.open-cluster-management.io/hosting-cluster-name": "cluster2", + }, + }, + Status: mcv1.ManagedClusterStatus{ + Conditions: []metav1.Condition{ + testcommon.NewConditionWithTime("ManagedClusterJoined", metav1.ConditionTrue, t2), + }, + }, + } + + mcWithoutCondition := &mcv1.ManagedCluster{ + ObjectMeta: metav1.ObjectMeta{ + Name: "cluster1", + CreationTimestamp: metav1.Time{Time: t1}, + }, + } + + tests := []testcommon.GenerateMetricsTestCase{ + { + Name: "test cluster status", + Obj: mc, + MetricNames: []string{"acm_managed_cluster_import_timestamp"}, + Want: fmt.Sprintf(`acm_managed_cluster_import_timestamp{managed_cluster_name="cluster1",managed_cluster_id="cluster1",hosting_cluster_name="cluster2",status="Created"} %.9e +acm_managed_cluster_import_timestamp{managed_cluster_name="cluster1",managed_cluster_id="cluster1",hosting_cluster_name="cluster2",status="Joined"} %.9e +acm_managed_cluster_import_timestamp{managed_cluster_name="cluster1",managed_cluster_id="cluster1",hosting_cluster_name="cluster2",status="ManagedClusterKubeconfigProvided"} %.9e +acm_managed_cluster_import_timestamp{managed_cluster_name="cluster1",managed_cluster_id="cluster1",hosting_cluster_name="cluster2",status="StartToApplyKlusterletResources"} %.9e`, + float64(t1.Unix()), float64(t2.Unix()), float64(t1.Unix()), float64(t2.Unix())), + }, + { + Name: "test cluster status without condition", + Obj: mcWithoutCondition, + MetricNames: []string{"acm_managed_cluster_import_timestamp"}, + Want: fmt.Sprintf(`acm_managed_cluster_import_timestamp{managed_cluster_name="cluster1",managed_cluster_id="cluster1",status="Created"} %.9e + acm_managed_cluster_import_timestamp{managed_cluster_name="cluster1",managed_cluster_id="cluster1",status="ManagedClusterKubeconfigProvided"} %.9e + acm_managed_cluster_import_timestamp{managed_cluster_name="cluster1",managed_cluster_id="cluster1",status="StartToApplyKlusterletResources"} %.9e`, + float64(t1.Unix()), float64(t1.Unix()), float64(t2.Unix())), + }, + } + + hubID := "hub" + clusterTimestampCache := map[string]map[string]float64{ + "cluster1": { + "ManagedClusterKubeconfigProvided": float64(t1.Unix()), + "StartToApplyKlusterletResources": float64(t2.Unix()), + }, + } + getClusterTimestamps := func(clusterName string) map[string]float64 { + return clusterTimestampCache[clusterName] + } + for i, c := range tests { + t.Run(c.Name, func(t *testing.T) { + c.Func = metric.ComposeMetricGenFuncs( + []metric.FamilyGenerator{GetManagedClusterTimestampMetricFamilies(hubID, getClusterTimestamps)}, + ) + if err := c.Run(); err != nil { + t.Errorf("unexpected collecting result in %v run:\n%s", i, err) + } + }) + } +} diff --git a/pkg/generators/utils.go b/pkg/generators/utils.go index d5820658..514872d6 100644 --- a/pkg/generators/utils.go +++ b/pkg/generators/utils.go @@ -51,3 +51,23 @@ func buildStatusConditionMetrics(conditionType string, conditionStatus metav1.Co return metrics } + +type TimestampStatusType string + +const ( + CreatedTimestamp TimestampStatusType = "Created" + AppliedTimestamp TimestampStatusType = "Applied" + JoinedTimestamp TimestampStatusType = "Joined" +) + +func BuildTimestampMetric(time metav1.Time, keys, values []string, status TimestampStatusType) *metric.Metric { + // do not use 'labelValues := append(labelValues, string(status))', prevent from using the shared backing array + labelKeys := append([]string{"status"}, keys...) + labelValues := append([]string{string(status)}, values...) + + return &metric.Metric{ + LabelKeys: labelKeys, + LabelValues: labelValues, + Value: float64(time.Unix()), + } +} diff --git a/pkg/generators/work/manifestworktimestamp.go b/pkg/generators/work/manifestworktimestamp.go new file mode 100644 index 00000000..1ff56fe9 --- /dev/null +++ b/pkg/generators/work/manifestworktimestamp.go @@ -0,0 +1,75 @@ +// Copyright (c) 2020 Red Hat, Inc. +// Copyright Contributors to the Open Cluster Management project + +package work + +import ( + "github.com/stolostron/clusterlifecycle-state-metrics/pkg/generators" + "k8s.io/apimachinery/pkg/api/meta" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/kube-state-metrics/pkg/metric" + workv1 "open-cluster-management.io/api/work/v1" + + "k8s.io/klog/v2" +) + +var ( + descWorkTimestampName = "acm_manifestwork_apply_timestamp" + descWorkTimestampHelp = "The timestamp of the manifestwork appled" + clusterServiceHostedClusterLabel = "api.openshift.com/management-cluster" + importHostedClusterLabel = "import.open-cluster-management.io/hosted-cluster" +) + +func GetManifestWorkTimestampMetricFamilies(getClusterIdFunc func(string) string) metric.FamilyGenerator { + return metric.FamilyGenerator{ + Name: descWorkTimestampName, + Type: metric.Gauge, + Help: descWorkTimestampHelp, + GenerateFunc: func(obj interface{}) *metric.Family { + mw, ok := obj.(*workv1.ManifestWork) + if !ok { + klog.Infof("Invalid ManifestWork: %v", obj) + return &metric.Family{Metrics: []*metric.Metric{}} + } + + hostedcluster := getHostedClusterName(mw) + if len(hostedcluster) == 0 { + return &metric.Family{Metrics: []*metric.Metric{}} + } + + klog.Infof("Hanlde ManifestWork %s/%s", mw.Namespace, mw.Name) + keys := []string{"manifestwork", "managed_cluster_name", "hosted_cluster_name"} + values := []string{mw.Name, mw.Namespace, hostedcluster} + if clusterId := getClusterIdFunc(mw.Namespace); len(clusterId) > 0 { + keys = append(keys, "managed_cluster_id") + values = append(values, clusterId) + } + + family := metric.Family{} + family.Metrics = append(family.Metrics, + generators.BuildTimestampMetric(mw.CreationTimestamp, keys, values, generators.CreatedTimestamp)) + + appliedCond := meta.FindStatusCondition(mw.Status.Conditions, workv1.WorkApplied) + if appliedCond != nil && appliedCond.Status == metav1.ConditionTrue { + family.Metrics = append(family.Metrics, generators.BuildTimestampMetric( + appliedCond.LastTransitionTime, keys, values, generators.AppliedTimestamp)) + } + klog.Infof("Returning %v", string(family.ByteSlice())) + return &family + }, + } +} + +func getHostedClusterName(mw *workv1.ManifestWork) string { + if len(mw.GetLabels()) == 0 { + return "" + } + if hostedcluster, ok := mw.GetLabels()[importHostedClusterLabel]; ok { + return hostedcluster + } + if hostedcluster, ok := mw.GetLabels()[clusterServiceHostedClusterLabel]; ok { + return hostedcluster + } + + return "" +} diff --git a/pkg/generators/work/manifestworktimestamp_test.go b/pkg/generators/work/manifestworktimestamp_test.go new file mode 100644 index 00000000..04ff5f3a --- /dev/null +++ b/pkg/generators/work/manifestworktimestamp_test.go @@ -0,0 +1,85 @@ +// Copyright (c) 2020 Red Hat, Inc. +// Copyright Contributors to the Open Cluster Management project + +package work + +import ( + "fmt" + "testing" + "time" + + testcommon "github.com/stolostron/clusterlifecycle-state-metrics/test/unit/common" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/kube-state-metrics/pkg/metric" + workv1 "open-cluster-management.io/api/work/v1" +) + +func Test_getManifestWorkTimestampMetricFamilies(t *testing.T) { + + t1, err := time.Parse(time.RFC3339, "2021-09-01T00:01:01Z") + if err != nil { + t.Errorf("unexpected error: %v", err) + } + t2, err := time.Parse(time.RFC3339, "2021-09-01T00:01:02Z") + if err != nil { + t.Errorf("unexpected error: %v", err) + } + + work := &workv1.ManifestWork{ + ObjectMeta: metav1.ObjectMeta{ + Name: "cluster2-hosted-klusterlet", + Namespace: "local-cluster", + CreationTimestamp: metav1.Time{Time: t1}, + Labels: map[string]string{ + importHostedClusterLabel: "cluster2", + }, + }, + Status: workv1.ManifestWorkStatus{ + Conditions: []metav1.Condition{ + testcommon.NewConditionWithTime("Applied", metav1.ConditionTrue, t2), + }, + }, + } + + workWithoutCondition := &workv1.ManifestWork{ + ObjectMeta: metav1.ObjectMeta{ + Name: "cluster2-hosted-klusterlet", + Namespace: "local-cluster", + CreationTimestamp: metav1.Time{ + Time: t1, + }, + Labels: map[string]string{ + importHostedClusterLabel: "cluster2", + }, + }, + } + + tests := []testcommon.GenerateMetricsTestCase{ + { + Name: "test work status", + Obj: work, + MetricNames: []string{"acm_manifestwork_apply_timestamp"}, + Want: fmt.Sprintf(`acm_manifestwork_apply_timestamp{manifestwork="cluster2-hosted-klusterlet",managed_cluster_name="local-cluster",hosted_cluster_name="cluster2",managed_cluster_id="local-cluster",status="Created"} %.9e +acm_manifestwork_apply_timestamp{manifestwork="cluster2-hosted-klusterlet",managed_cluster_name="local-cluster",hosted_cluster_name="cluster2",managed_cluster_id="local-cluster",status="Applied"} %.9e`, float64(t1.Unix()), float64(t2.Unix())), + }, + { + Name: "test work status without condition", + Obj: workWithoutCondition, + MetricNames: []string{"acm_manifestwork_apply_timestamp"}, + Want: fmt.Sprintf(`acm_manifestwork_apply_timestamp{manifestwork="cluster2-hosted-klusterlet",managed_cluster_name="local-cluster",hosted_cluster_name="cluster2",managed_cluster_id="local-cluster",status="Created"} %.9e`, float64(t1.Unix())), + }, + } + + for i, c := range tests { + t.Run(c.Name, func(t *testing.T) { + c.Func = metric.ComposeMetricGenFuncs( + []metric.FamilyGenerator{GetManifestWorkTimestampMetricFamilies(func(clusterName string) string { + return clusterName + })}, + ) + if err := c.Run(); err != nil { + t.Errorf("unexpected collecting result in %v run:\n%s", i, err) + } + }) + } +} diff --git a/test/unit/common/testutils.go b/test/unit/common/testutils.go index 5f3173f5..e15c569f 100644 --- a/test/unit/common/testutils.go +++ b/test/unit/common/testutils.go @@ -8,6 +8,7 @@ import ( "regexp" "sort" "strings" + "time" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metricsstore "k8s.io/kube-state-metrics/pkg/metrics_store" @@ -153,3 +154,11 @@ func NewCondition(conditonType string, status metav1.ConditionStatus) metav1.Con Status: status, } } + +func NewConditionWithTime(conditonType string, status metav1.ConditionStatus, t time.Time) metav1.Condition { + return metav1.Condition{ + Type: conditonType, + Status: status, + LastTransitionTime: metav1.NewTime(t), + } +} diff --git a/vendor/modules.txt b/vendor/modules.txt index b13c2391..1b49419d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -693,6 +693,7 @@ open-cluster-management.io/api/client/work/clientset/versioned/typed/work/v1 open-cluster-management.io/api/cluster/v1 open-cluster-management.io/api/cluster/v1alpha1 open-cluster-management.io/api/cluster/v1beta1 +open-cluster-management.io/api/operator/v1 open-cluster-management.io/api/work/v1 # sigs.k8s.io/controller-runtime v0.12.3 ## explicit; go 1.17 diff --git a/vendor/open-cluster-management.io/api/operator/v1/0000_00_operator.open-cluster-management.io_klusterlets.crd.yaml b/vendor/open-cluster-management.io/api/operator/v1/0000_00_operator.open-cluster-management.io_klusterlets.crd.yaml new file mode 100644 index 00000000..0bb82f7e --- /dev/null +++ b/vendor/open-cluster-management.io/api/operator/v1/0000_00_operator.open-cluster-management.io_klusterlets.crd.yaml @@ -0,0 +1,246 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: klusterlets.operator.open-cluster-management.io +spec: + group: operator.open-cluster-management.io + names: + kind: Klusterlet + listKind: KlusterletList + plural: klusterlets + singular: klusterlet + scope: Cluster + preserveUnknownFields: false + versions: + - name: v1 + schema: + openAPIV3Schema: + description: Klusterlet represents controllers to install the resources for a managed cluster. When configured, the Klusterlet requires a secret named bootstrap-hub-kubeconfig in the agent namespace to allow API requests to the hub for the registration protocol. In Hosted mode, the Klusterlet requires an additional secret named external-managed-kubeconfig in the agent namespace to allow API requests to the managed cluster for resources installation. + type: object + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: Spec represents the desired deployment configuration of Klusterlet agent. + type: object + properties: + clusterName: + description: ClusterName is the name of the managed cluster to be created on hub. The Klusterlet agent generates a random name if it is not set, or discovers the appropriate cluster name on OpenShift. + type: string + deployOption: + description: DeployOption contains the options of deploying a klusterlet + type: object + properties: + mode: + description: 'Mode can be Default or Hosted. It is Default mode if not specified In Default mode, all klusterlet related resources are deployed on the managed cluster. In Hosted mode, only crd and configurations are installed on the spoke/managed cluster. Controllers run in another cluster (defined as management-cluster) and connect to the mangaged cluster with the kubeconfig in secret of "external-managed-kubeconfig"(a kubeconfig of managed-cluster with cluster-admin permission). Note: Do not modify the Mode field once it''s applied.' + type: string + externalServerURLs: + description: ExternalServerURLs represents the a list of apiserver urls and ca bundles that is accessible externally If it is set empty, managed cluster has no externally accessible url that hub cluster can visit. + type: array + items: + description: ServerURL represents the apiserver url and ca bundle that is accessible externally + type: object + properties: + caBundle: + description: CABundle is the ca bundle to connect to apiserver of the managed cluster. System certs are used if it is not set. + type: string + format: byte + url: + description: URL is the url of apiserver endpoint of the managed cluster. + type: string + hubApiServerHostAlias: + description: HubApiServerHostAlias contains the host alias for hub api server. registration-agent and work-agent will use it to communicate with hub api server. + type: object + required: + - hostname + - ip + properties: + hostname: + description: Hostname for the above IP address. + type: string + pattern: ^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$ + ip: + description: IP address of the host file entry. + type: string + pattern: ^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$ + namespace: + description: Namespace is the namespace to deploy the agent on the managed cluster. The namespace must have a prefix of "open-cluster-management-", and if it is not set, the namespace of "open-cluster-management-agent" is used to deploy agent. In addition, the add-ons are deployed to the namespace of "{Namespace}-addon". In the Hosted mode, this namespace still exists on the managed cluster to contain necessary resources, like service accounts, roles and rolebindings, while the agent is deployed to the namespace with the same name as klusterlet on the management cluster. + type: string + maxLength: 63 + pattern: ^open-cluster-management-[-a-z0-9]*[a-z0-9]$ + nodePlacement: + description: NodePlacement enables explicit control over the scheduling of the deployed pods. + type: object + properties: + nodeSelector: + description: NodeSelector defines which Nodes the Pods are scheduled on. The default is an empty list. + type: object + additionalProperties: + type: string + tolerations: + description: Tolerations is attached by pods to tolerate any taint that matches the triple using the matching operator . The default is an empty list. + type: array + items: + description: The pod this Toleration is attached to tolerates any taint that matches the triple using the matching operator . + type: object + properties: + effect: + description: Effect indicates the taint effect to match. Empty means match all taint effects. When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute. + type: string + key: + description: Key is the taint key that the toleration applies to. Empty means match all taint keys. If the key is empty, operator must be Exists; this combination means to match all values and all keys. + type: string + operator: + description: Operator represents a key's relationship to the value. Valid operators are Exists and Equal. Defaults to Equal. Exists is equivalent to wildcard for value, so that a pod can tolerate all taints of a particular category. + type: string + tolerationSeconds: + description: TolerationSeconds represents the period of time the toleration (which must be of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default, it is not set, which means tolerate the taint forever (do not evict). Zero and negative values will be treated as 0 (evict immediately) by the system. + type: integer + format: int64 + value: + description: Value is the taint value the toleration matches to. If the operator is Exists, the value should be empty, otherwise just a regular string. + type: string + registrationConfiguration: + description: RegistrationConfiguration contains the configuration of registration + type: object + properties: + featureGates: + description: "FeatureGates represents the list of feature gates for registration If it is set empty, default feature gates will be used. If it is set, featuregate/Foo is an example of one item in FeatureGates: 1. If featuregate/Foo does not exist, registration-operator will discard it 2. If featuregate/Foo exists and is false by default. It is now possible to set featuregate/Foo=[false|true] 3. If featuregate/Foo exists and is true by default. If a cluster-admin upgrading from 1 to 2 wants to continue having featuregate/Foo=false, \the can set featuregate/Foo=false before upgrading. Let's say the cluster-admin wants featuregate/Foo=false." + type: array + items: + type: object + required: + - feature + properties: + feature: + description: Feature is the key of feature gate. e.g. featuregate/Foo. + type: string + mode: + description: Mode is either Enable, Disable, "" where "" is Disable by default. In Enable mode, a valid feature gate `featuregate/Foo` will be set to "--featuregate/Foo=true". In Disable mode, a valid feature gate `featuregate/Foo` will be set to "--featuregate/Foo=false". + type: string + default: Disable + enum: + - Enable + - Disable + registrationImagePullSpec: + description: RegistrationImagePullSpec represents the desired image configuration of registration agent. quay.io/open-cluster-management.io/registration:latest will be used if unspecified. + type: string + workImagePullSpec: + description: WorkImagePullSpec represents the desired image configuration of work agent. quay.io/open-cluster-management.io/work:latest will be used if unspecified. + type: string + status: + description: Status represents the current status of Klusterlet agent. + type: object + properties: + conditions: + description: 'Conditions contain the different condition statuses for this Klusterlet. Valid condition types are: Applied: Components have been applied in the managed cluster. Available: Components in the managed cluster are available and ready to serve. Progressing: Components in the managed cluster are in a transitioning state. Degraded: Components in the managed cluster do not match the desired configuration and only provide degraded service.' + type: array + items: + description: "Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }" + type: object + required: + - lastTransitionTime + - message + - reason + - status + - type + properties: + lastTransitionTime: + description: lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + type: string + format: date-time + message: + description: message is a human readable message indicating details about the transition. This may be an empty string. + type: string + maxLength: 32768 + observedGeneration: + description: observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. + type: integer + format: int64 + minimum: 0 + reason: + description: reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty. + type: string + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + status: + description: status of the condition, one of True, False, Unknown. + type: string + enum: + - "True" + - "False" + - Unknown + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. --- Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be useful (see .node.status.conditions), the ability to deconflict is important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) + type: string + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + generations: + description: Generations are used to determine when an item needs to be reconciled or has changed in a way that needs a reaction. + type: array + items: + description: GenerationStatus keeps track of the generation for a given resource so that decisions about forced updates can be made. The definition matches the GenerationStatus defined in github.com/openshift/api/v1 + type: object + properties: + group: + description: group is the group of the resource that you're tracking + type: string + lastGeneration: + description: lastGeneration is the last generation of the resource that controller applies + type: integer + format: int64 + name: + description: name is the name of the resource that you're tracking + type: string + namespace: + description: namespace is where the resource that you're tracking is + type: string + resource: + description: resource is the resource type of the resource that you're tracking + type: string + version: + description: version is the version of the resource that you're tracking + type: string + observedGeneration: + description: ObservedGeneration is the last generation change you've dealt with + type: integer + format: int64 + relatedResources: + description: RelatedResources are used to track the resources that are related to this Klusterlet. + type: array + items: + description: RelatedResourceMeta represents the resource that is managed by an operator + type: object + properties: + group: + description: group is the group of the resource that you're tracking + type: string + name: + description: name is the name of the resource that you're tracking + type: string + namespace: + description: namespace is where the thing you're tracking is + type: string + resource: + description: resource is the resource type of the resource that you're tracking + type: string + version: + description: version is the version of the thing you're tracking + type: string + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/vendor/open-cluster-management.io/api/operator/v1/0000_01_operator.open-cluster-management.io_clustermanagers.crd.yaml b/vendor/open-cluster-management.io/api/operator/v1/0000_01_operator.open-cluster-management.io_clustermanagers.crd.yaml new file mode 100644 index 00000000..c40c6471 --- /dev/null +++ b/vendor/open-cluster-management.io/api/operator/v1/0000_01_operator.open-cluster-management.io_clustermanagers.crd.yaml @@ -0,0 +1,262 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: clustermanagers.operator.open-cluster-management.io +spec: + group: operator.open-cluster-management.io + names: + kind: ClusterManager + listKind: ClusterManagerList + plural: clustermanagers + singular: clustermanager + scope: Cluster + preserveUnknownFields: false + versions: + - name: v1 + schema: + openAPIV3Schema: + description: ClusterManager configures the controllers on the hub that govern registration and work distribution for attached Klusterlets. In Default mode, ClusterManager will only be deployed in open-cluster-management-hub namespace. In Hosted mode, ClusterManager will be deployed in the namespace with the same name as cluster manager. + type: object + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: Spec represents a desired deployment configuration of controllers that govern registration and work distribution for attached Klusterlets. + type: object + default: + deployOption: + mode: Default + properties: + deployOption: + description: DeployOption contains the options of deploying a cluster-manager Default mode is used if DeployOption is not set. + type: object + default: + mode: Default + required: + - mode + properties: + hosted: + description: Hosted includes configurations we needs for clustermanager in the Hosted mode. + type: object + properties: + registrationWebhookConfiguration: + description: RegistrationWebhookConfiguration represents the customized webhook-server configuration of registration. + type: object + required: + - address + properties: + address: + description: Address represents the address of a webhook-server. It could be in IP format or fqdn format. The Address must be reachable by apiserver of the hub cluster. + type: string + pattern: ^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$ + port: + description: Port represents the port of a webhook-server. The default value of Port is 443. + type: integer + format: int32 + default: 443 + maximum: 65535 + workWebhookConfiguration: + description: WorkWebhookConfiguration represents the customized webhook-server configuration of work. + type: object + required: + - address + properties: + address: + description: Address represents the address of a webhook-server. It could be in IP format or fqdn format. The Address must be reachable by apiserver of the hub cluster. + type: string + pattern: ^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$ + port: + description: Port represents the port of a webhook-server. The default value of Port is 443. + type: integer + format: int32 + default: 443 + maximum: 65535 + mode: + description: 'Mode can be Default or Hosted. In Default mode, the Hub is installed as a whole and all parts of Hub are deployed in the same cluster. In Hosted mode, only crd and configurations are installed on one cluster(defined as hub-cluster). Controllers run in another cluster (defined as management-cluster) and connect to the hub with the kubeconfig in secret of "external-hub-kubeconfig"(a kubeconfig of hub-cluster with cluster-admin permission). Note: Do not modify the Mode field once it''s applied.' + type: string + default: Default + enum: + - Default + - Hosted + nodePlacement: + description: NodePlacement enables explicit control over the scheduling of the deployed pods. + type: object + properties: + nodeSelector: + description: NodeSelector defines which Nodes the Pods are scheduled on. The default is an empty list. + type: object + additionalProperties: + type: string + tolerations: + description: Tolerations is attached by pods to tolerate any taint that matches the triple using the matching operator . The default is an empty list. + type: array + items: + description: The pod this Toleration is attached to tolerates any taint that matches the triple using the matching operator . + type: object + properties: + effect: + description: Effect indicates the taint effect to match. Empty means match all taint effects. When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute. + type: string + key: + description: Key is the taint key that the toleration applies to. Empty means match all taint keys. If the key is empty, operator must be Exists; this combination means to match all values and all keys. + type: string + operator: + description: Operator represents a key's relationship to the value. Valid operators are Exists and Equal. Defaults to Equal. Exists is equivalent to wildcard for value, so that a pod can tolerate all taints of a particular category. + type: string + tolerationSeconds: + description: TolerationSeconds represents the period of time the toleration (which must be of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default, it is not set, which means tolerate the taint forever (do not evict). Zero and negative values will be treated as 0 (evict immediately) by the system. + type: integer + format: int64 + value: + description: Value is the taint value the toleration matches to. If the operator is Exists, the value should be empty, otherwise just a regular string. + type: string + placementImagePullSpec: + description: PlacementImagePullSpec represents the desired image configuration of placement controller/webhook installed on hub. + type: string + default: quay.io/open-cluster-management/placement + registrationConfiguration: + description: RegistrationConfiguration contains the configuration of registration + type: object + properties: + featureGates: + description: "FeatureGates represents the list of feature gates for registration If it is set empty, default feature gates will be used. If it is set, featuregate/Foo is an example of one item in FeatureGates: 1. If featuregate/Foo does not exist, registration-operator will discard it 2. If featuregate/Foo exists and is false by default. It is now possible to set featuregate/Foo=[false|true] 3. If featuregate/Foo exists and is true by default. If a cluster-admin upgrading from 1 to 2 wants to continue having featuregate/Foo=false, \the can set featuregate/Foo=false before upgrading. Let's say the cluster-admin wants featuregate/Foo=false." + type: array + items: + type: object + required: + - feature + properties: + feature: + description: Feature is the key of feature gate. e.g. featuregate/Foo. + type: string + mode: + description: Mode is either Enable, Disable, "" where "" is Disable by default. In Enable mode, a valid feature gate `featuregate/Foo` will be set to "--featuregate/Foo=true". In Disable mode, a valid feature gate `featuregate/Foo` will be set to "--featuregate/Foo=false". + type: string + default: Disable + enum: + - Enable + - Disable + registrationImagePullSpec: + description: RegistrationImagePullSpec represents the desired image of registration controller/webhook installed on hub. + type: string + default: quay.io/open-cluster-management/registration + workImagePullSpec: + description: WorkImagePullSpec represents the desired image configuration of work controller/webhook installed on hub. + type: string + default: quay.io/open-cluster-management/work + status: + description: Status represents the current status of controllers that govern the lifecycle of managed clusters. + type: object + properties: + conditions: + description: 'Conditions contain the different condition statuses for this ClusterManager. Valid condition types are: Applied: Components in hub are applied. Available: Components in hub are available and ready to serve. Progressing: Components in hub are in a transitioning state. Degraded: Components in hub do not match the desired configuration and only provide degraded service.' + type: array + items: + description: "Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }" + type: object + required: + - lastTransitionTime + - message + - reason + - status + - type + properties: + lastTransitionTime: + description: lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + type: string + format: date-time + message: + description: message is a human readable message indicating details about the transition. This may be an empty string. + type: string + maxLength: 32768 + observedGeneration: + description: observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. + type: integer + format: int64 + minimum: 0 + reason: + description: reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty. + type: string + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + status: + description: status of the condition, one of True, False, Unknown. + type: string + enum: + - "True" + - "False" + - Unknown + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. --- Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be useful (see .node.status.conditions), the ability to deconflict is important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) + type: string + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + generations: + description: Generations are used to determine when an item needs to be reconciled or has changed in a way that needs a reaction. + type: array + items: + description: GenerationStatus keeps track of the generation for a given resource so that decisions about forced updates can be made. The definition matches the GenerationStatus defined in github.com/openshift/api/v1 + type: object + properties: + group: + description: group is the group of the resource that you're tracking + type: string + lastGeneration: + description: lastGeneration is the last generation of the resource that controller applies + type: integer + format: int64 + name: + description: name is the name of the resource that you're tracking + type: string + namespace: + description: namespace is where the resource that you're tracking is + type: string + resource: + description: resource is the resource type of the resource that you're tracking + type: string + version: + description: version is the version of the resource that you're tracking + type: string + observedGeneration: + description: ObservedGeneration is the last generation change you've dealt with + type: integer + format: int64 + relatedResources: + description: RelatedResources are used to track the resources that are related to this ClusterManager. + type: array + items: + description: RelatedResourceMeta represents the resource that is managed by an operator + type: object + properties: + group: + description: group is the group of the resource that you're tracking + type: string + name: + description: name is the name of the resource that you're tracking + type: string + namespace: + description: namespace is where the thing you're tracking is + type: string + resource: + description: resource is the resource type of the resource that you're tracking + type: string + version: + description: version is the version of the thing you're tracking + type: string + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/vendor/open-cluster-management.io/api/operator/v1/0001_00_operator.open-cluster-management.io_klusterlets.crd.yaml b/vendor/open-cluster-management.io/api/operator/v1/0001_00_operator.open-cluster-management.io_klusterlets.crd.yaml new file mode 100644 index 00000000..fdf9a489 --- /dev/null +++ b/vendor/open-cluster-management.io/api/operator/v1/0001_00_operator.open-cluster-management.io_klusterlets.crd.yaml @@ -0,0 +1,248 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + name: klusterlets.operator.open-cluster-management.io +spec: + group: operator.open-cluster-management.io + names: + kind: Klusterlet + listKind: KlusterletList + plural: klusterlets + singular: klusterlet + scope: Cluster + subresources: + status: {} + validation: + openAPIV3Schema: + description: Klusterlet represents controllers to install the resources for a managed cluster. When configured, the Klusterlet requires a secret named bootstrap-hub-kubeconfig in the agent namespace to allow API requests to the hub for the registration protocol. In Hosted mode, the Klusterlet requires an additional secret named external-managed-kubeconfig in the agent namespace to allow API requests to the managed cluster for resources installation. + type: object + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: Spec represents the desired deployment configuration of Klusterlet agent. + type: object + properties: + clusterName: + description: ClusterName is the name of the managed cluster to be created on hub. The Klusterlet agent generates a random name if it is not set, or discovers the appropriate cluster name on OpenShift. + type: string + deployOption: + description: DeployOption contains the options of deploying a klusterlet + type: object + properties: + mode: + description: 'Mode can be Default or Hosted. It is Default mode if not specified In Default mode, all klusterlet related resources are deployed on the managed cluster. In Hosted mode, only crd and configurations are installed on the spoke/managed cluster. Controllers run in another cluster (defined as management-cluster) and connect to the mangaged cluster with the kubeconfig in secret of "external-managed-kubeconfig"(a kubeconfig of managed-cluster with cluster-admin permission). Note: Do not modify the Mode field once it''s applied.' + type: string + externalServerURLs: + description: ExternalServerURLs represents the a list of apiserver urls and ca bundles that is accessible externally If it is set empty, managed cluster has no externally accessible url that hub cluster can visit. + type: array + items: + description: ServerURL represents the apiserver url and ca bundle that is accessible externally + type: object + properties: + caBundle: + description: CABundle is the ca bundle to connect to apiserver of the managed cluster. System certs are used if it is not set. + type: string + format: byte + url: + description: URL is the url of apiserver endpoint of the managed cluster. + type: string + hubApiServerHostAlias: + description: HubApiServerHostAlias contains the host alias for hub api server. registration-agent and work-agent will use it to communicate with hub api server. + type: object + required: + - hostname + - ip + properties: + hostname: + description: Hostname for the above IP address. + type: string + pattern: ^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$ + ip: + description: IP address of the host file entry. + type: string + pattern: ^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$ + namespace: + description: Namespace is the namespace to deploy the agent on the managed cluster. The namespace must have a prefix of "open-cluster-management-", and if it is not set, the namespace of "open-cluster-management-agent" is used to deploy agent. In addition, the add-ons are deployed to the namespace of "{Namespace}-addon". In the Hosted mode, this namespace still exists on the managed cluster to contain necessary resources, like service accounts, roles and rolebindings, while the agent is deployed to the namespace with the same name as klusterlet on the management cluster. + type: string + maxLength: 63 + pattern: ^open-cluster-management-[-a-z0-9]*[a-z0-9]$ + nodePlacement: + description: NodePlacement enables explicit control over the scheduling of the deployed pods. + type: object + properties: + nodeSelector: + description: NodeSelector defines which Nodes the Pods are scheduled on. The default is an empty list. + type: object + additionalProperties: + type: string + tolerations: + description: Tolerations is attached by pods to tolerate any taint that matches the triple using the matching operator . The default is an empty list. + type: array + items: + description: The pod this Toleration is attached to tolerates any taint that matches the triple using the matching operator . + type: object + properties: + effect: + description: Effect indicates the taint effect to match. Empty means match all taint effects. When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute. + type: string + key: + description: Key is the taint key that the toleration applies to. Empty means match all taint keys. If the key is empty, operator must be Exists; this combination means to match all values and all keys. + type: string + operator: + description: Operator represents a key's relationship to the value. Valid operators are Exists and Equal. Defaults to Equal. Exists is equivalent to wildcard for value, so that a pod can tolerate all taints of a particular category. + type: string + tolerationSeconds: + description: TolerationSeconds represents the period of time the toleration (which must be of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default, it is not set, which means tolerate the taint forever (do not evict). Zero and negative values will be treated as 0 (evict immediately) by the system. + type: integer + format: int64 + value: + description: Value is the taint value the toleration matches to. If the operator is Exists, the value should be empty, otherwise just a regular string. + type: string + registrationConfiguration: + description: RegistrationConfiguration contains the configuration of registration + type: object + properties: + featureGates: + description: "FeatureGates represents the list of feature gates for registration If it is set empty, default feature gates will be used. If it is set, featuregate/Foo is an example of one item in FeatureGates: 1. If featuregate/Foo does not exist, registration-operator will discard it 2. If featuregate/Foo exists and is false by default. It is now possible to set featuregate/Foo=[false|true] 3. If featuregate/Foo exists and is true by default. If a cluster-admin upgrading from 1 to 2 wants to continue having featuregate/Foo=false, \the can set featuregate/Foo=false before upgrading. Let's say the cluster-admin wants featuregate/Foo=false." + type: array + items: + type: object + required: + - feature + properties: + feature: + description: Feature is the key of feature gate. e.g. featuregate/Foo. + type: string + mode: + description: Mode is either Enable, Disable, "" where "" is Disable by default. In Enable mode, a valid feature gate `featuregate/Foo` will be set to "--featuregate/Foo=true". In Disable mode, a valid feature gate `featuregate/Foo` will be set to "--featuregate/Foo=false". + type: string + default: Disable + enum: + - Enable + - Disable + registrationImagePullSpec: + description: RegistrationImagePullSpec represents the desired image configuration of registration agent. quay.io/open-cluster-management.io/registration:latest will be used if unspecified. + type: string + workImagePullSpec: + description: WorkImagePullSpec represents the desired image configuration of work agent. quay.io/open-cluster-management.io/work:latest will be used if unspecified. + type: string + status: + description: Status represents the current status of Klusterlet agent. + type: object + properties: + conditions: + description: 'Conditions contain the different condition statuses for this Klusterlet. Valid condition types are: Applied: Components have been applied in the managed cluster. Available: Components in the managed cluster are available and ready to serve. Progressing: Components in the managed cluster are in a transitioning state. Degraded: Components in the managed cluster do not match the desired configuration and only provide degraded service.' + type: array + items: + description: "Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }" + type: object + required: + - lastTransitionTime + - message + - reason + - status + - type + properties: + lastTransitionTime: + description: lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + type: string + format: date-time + message: + description: message is a human readable message indicating details about the transition. This may be an empty string. + type: string + maxLength: 32768 + observedGeneration: + description: observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. + type: integer + format: int64 + minimum: 0 + reason: + description: reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty. + type: string + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + status: + description: status of the condition, one of True, False, Unknown. + type: string + enum: + - "True" + - "False" + - Unknown + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. --- Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be useful (see .node.status.conditions), the ability to deconflict is important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) + type: string + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + generations: + description: Generations are used to determine when an item needs to be reconciled or has changed in a way that needs a reaction. + type: array + items: + description: GenerationStatus keeps track of the generation for a given resource so that decisions about forced updates can be made. The definition matches the GenerationStatus defined in github.com/openshift/api/v1 + type: object + properties: + group: + description: group is the group of the resource that you're tracking + type: string + lastGeneration: + description: lastGeneration is the last generation of the resource that controller applies + type: integer + format: int64 + name: + description: name is the name of the resource that you're tracking + type: string + namespace: + description: namespace is where the resource that you're tracking is + type: string + resource: + description: resource is the resource type of the resource that you're tracking + type: string + version: + description: version is the version of the resource that you're tracking + type: string + observedGeneration: + description: ObservedGeneration is the last generation change you've dealt with + type: integer + format: int64 + relatedResources: + description: RelatedResources are used to track the resources that are related to this Klusterlet. + type: array + items: + description: RelatedResourceMeta represents the resource that is managed by an operator + type: object + properties: + group: + description: group is the group of the resource that you're tracking + type: string + name: + description: name is the name of the resource that you're tracking + type: string + namespace: + description: namespace is where the thing you're tracking is + type: string + resource: + description: resource is the resource type of the resource that you're tracking + type: string + version: + description: version is the version of the thing you're tracking + type: string + version: v1 + versions: + - name: v1 + served: true + storage: true + preserveUnknownFields: false +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/vendor/open-cluster-management.io/api/operator/v1/doc.go b/vendor/open-cluster-management.io/api/operator/v1/doc.go new file mode 100644 index 00000000..d2fe07ae --- /dev/null +++ b/vendor/open-cluster-management.io/api/operator/v1/doc.go @@ -0,0 +1,9 @@ +// Package v1 contains API Schema definitions for the operator v1 API group +// +k8s:deepcopy-gen=package,register +// +k8s:conversion-gen=open-cluster-management.io/api/operator +// +k8s:defaulter-gen=TypeMeta +// +k8s:openapi-gen=true + +// +kubebuilder:validation:Optional +// +groupName=operator.open-cluster-management.io +package v1 diff --git a/vendor/open-cluster-management.io/api/operator/v1/register.go b/vendor/open-cluster-management.io/api/operator/v1/register.go new file mode 100644 index 00000000..0c06e121 --- /dev/null +++ b/vendor/open-cluster-management.io/api/operator/v1/register.go @@ -0,0 +1,39 @@ +package v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var ( + GroupName = "operator.open-cluster-management.io" + GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"} + schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + // Install is a function which adds this version to a scheme + Install = schemeBuilder.AddToScheme + + // SchemeGroupVersion generated code relies on this name + // Deprecated + SchemeGroupVersion = GroupVersion + // AddToScheme exists solely to keep the old generators creating valid code + // DEPRECATED + AddToScheme = schemeBuilder.AddToScheme +) + +// Resource generated code relies on this being here, but it logically belongs to the group +// DEPRECATED +func Resource(resource string) schema.GroupResource { + return schema.GroupResource{Group: GroupName, Resource: resource} +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(GroupVersion, + &ClusterManager{}, + &ClusterManagerList{}, + &Klusterlet{}, + &KlusterletList{}) + metav1.AddToGroupVersion(scheme, GroupVersion) + return nil +} diff --git a/vendor/open-cluster-management.io/api/operator/v1/types.go b/vendor/open-cluster-management.io/api/operator/v1/types.go new file mode 100644 index 00000000..07131426 --- /dev/null +++ b/vendor/open-cluster-management.io/api/operator/v1/types.go @@ -0,0 +1,416 @@ +package v1 + +import ( + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:subresource:status +// +kubebuilder:resource:scope=Cluster + +// ClusterManager configures the controllers on the hub that govern registration and work distribution for attached Klusterlets. +// In Default mode, ClusterManager will only be deployed in open-cluster-management-hub namespace. +// In Hosted mode, ClusterManager will be deployed in the namespace with the same name as cluster manager. +type ClusterManager struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec represents a desired deployment configuration of controllers that govern registration and work distribution for attached Klusterlets. + // +kubebuilder:default={deployOption: {mode: Default}} + Spec ClusterManagerSpec `json:"spec"` + + // Status represents the current status of controllers that govern the lifecycle of managed clusters. + // +optional + Status ClusterManagerStatus `json:"status,omitempty"` +} + +// ClusterManagerSpec represents a desired deployment configuration of controllers that govern registration and work distribution for attached Klusterlets. +type ClusterManagerSpec struct { + // RegistrationImagePullSpec represents the desired image of registration controller/webhook installed on hub. + // +optional + // +kubebuilder:default=quay.io/open-cluster-management/registration + RegistrationImagePullSpec string `json:"registrationImagePullSpec,omitempty"` + + // WorkImagePullSpec represents the desired image configuration of work controller/webhook installed on hub. + // +optional + // +kubebuilder:default=quay.io/open-cluster-management/work + WorkImagePullSpec string `json:"workImagePullSpec,omitempty"` + + // PlacementImagePullSpec represents the desired image configuration of placement controller/webhook installed on hub. + // +optional + // +kubebuilder:default=quay.io/open-cluster-management/placement + PlacementImagePullSpec string `json:"placementImagePullSpec,omitempty"` + + // NodePlacement enables explicit control over the scheduling of the deployed pods. + // +optional + NodePlacement NodePlacement `json:"nodePlacement,omitempty"` + + // DeployOption contains the options of deploying a cluster-manager + // Default mode is used if DeployOption is not set. + // +optional + // +kubebuilder:default={mode: Default} + DeployOption ClusterManagerDeployOption `json:"deployOption,omitempty"` + + // RegistrationConfiguration contains the configuration of registration + // +optional + RegistrationConfiguration *RegistrationConfiguration `json:"registrationConfiguration,omitempty"` +} + +type RegistrationConfiguration struct { + // FeatureGates represents the list of feature gates for registration + // If it is set empty, default feature gates will be used. + // If it is set, featuregate/Foo is an example of one item in FeatureGates: + // 1. If featuregate/Foo does not exist, registration-operator will discard it + // 2. If featuregate/Foo exists and is false by default. It is now possible to set featuregate/Foo=[false|true] + // 3. If featuregate/Foo exists and is true by default. If a cluster-admin upgrading from 1 to 2 wants to continue having featuregate/Foo=false, + // he can set featuregate/Foo=false before upgrading. Let's say the cluster-admin wants featuregate/Foo=false. + // +optional + FeatureGates []FeatureGate `json:"featureGates,omitempty"` +} + +type FeatureGate struct { + // Feature is the key of feature gate. e.g. featuregate/Foo. + // +kubebuilder:validation:Required + // +required + Feature string `json:"feature"` + + // Mode is either Enable, Disable, "" where "" is Disable by default. + // In Enable mode, a valid feature gate `featuregate/Foo` will be set to "--featuregate/Foo=true". + // In Disable mode, a valid feature gate `featuregate/Foo` will be set to "--featuregate/Foo=false". + // +kubebuilder:default:=Disable + // +kubebuilder:validation:Enum:=Enable;Disable + // +optional + Mode FeatureGateModeType `json:"mode,omitempty"` +} + +type FeatureGateModeType string + +const ( + // Valid FeatureGateModeType value is Enable, Disable. + FeatureGateModeTypeEnable FeatureGateModeType = "Enable" + FeatureGateModeTypeDisable FeatureGateModeType = "Disable" +) + +// HostedClusterManagerConfiguration represents customized configurations we need to set for clustermanager in the Hosted mode. +type HostedClusterManagerConfiguration struct { + // RegistrationWebhookConfiguration represents the customized webhook-server configuration of registration. + // +optional + RegistrationWebhookConfiguration WebhookConfiguration `json:"registrationWebhookConfiguration,omitempty"` + + // WorkWebhookConfiguration represents the customized webhook-server configuration of work. + // +optional + WorkWebhookConfiguration WebhookConfiguration `json:"workWebhookConfiguration,omitempty"` +} + +// WebhookConfiguration has two properties: Address and Port. +type WebhookConfiguration struct { + // Address represents the address of a webhook-server. + // It could be in IP format or fqdn format. + // The Address must be reachable by apiserver of the hub cluster. + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:Pattern=^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$ + Address string `json:"address"` + + // Port represents the port of a webhook-server. The default value of Port is 443. + // +optional + // +default=443 + // +kubebuilder:default=443 + // +kubebuilder:validation:Maximum=65535 + Port int32 `json:"port,omitempty"` +} + +// KlusterletDeployOption describes the deploy options for klusterlet +type KlusterletDeployOption struct { + // Mode can be Default or Hosted. It is Default mode if not specified + // In Default mode, all klusterlet related resources are deployed on the managed cluster. + // In Hosted mode, only crd and configurations are installed on the spoke/managed cluster. Controllers run in another + // cluster (defined as management-cluster) and connect to the mangaged cluster with the kubeconfig in secret of + // "external-managed-kubeconfig"(a kubeconfig of managed-cluster with cluster-admin permission). + // Note: Do not modify the Mode field once it's applied. + // +optional + Mode InstallMode `json:"mode"` +} + +// ClusterManagerDeployOption describes the deploy options for cluster-manager +type ClusterManagerDeployOption struct { + // Mode can be Default or Hosted. + // In Default mode, the Hub is installed as a whole and all parts of Hub are deployed in the same cluster. + // In Hosted mode, only crd and configurations are installed on one cluster(defined as hub-cluster). Controllers run in another + // cluster (defined as management-cluster) and connect to the hub with the kubeconfig in secret of "external-hub-kubeconfig"(a kubeconfig + // of hub-cluster with cluster-admin permission). + // Note: Do not modify the Mode field once it's applied. + // +required + // +default=Default + // +kubebuilder:validation:Required + // +kubebuilder:default=Default + // +kubebuilder:validation:Enum=Default;Hosted + Mode InstallMode `json:"mode,omitempty"` + + // Hosted includes configurations we needs for clustermanager in the Hosted mode. + // +optional + Hosted *HostedClusterManagerConfiguration `json:"hosted,omitempty"` +} + +// InstallMode represents the mode of deploy cluster-manager or klusterlet +type InstallMode string + +const ( + // InstallModeDefault is the default deploy mode. + // The cluster-manager will be deployed in the hub-cluster, the klusterlet will be deployed in the managed-cluster. + InstallModeDefault InstallMode = "Default" + + // InstallModeDetached means deploying components outside. + // The cluster-manager will be deployed outside of the hub-cluster, the klusterlet will be deployed outside of the managed-cluster. + // DEPRECATED: please use Hosted instead. + InstallModeDetached InstallMode = "Detached" + + // InstallModeHosted means deploying components outside. + // The cluster-manager will be deployed outside of the hub-cluster, the klusterlet will be deployed outside of the managed-cluster. + InstallModeHosted InstallMode = "Hosted" +) + +// ClusterManagerStatus represents the current status of the registration and work distribution controllers running on the hub. +type ClusterManagerStatus struct { + // ObservedGeneration is the last generation change you've dealt with + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` + + // Conditions contain the different condition statuses for this ClusterManager. + // Valid condition types are: + // Applied: Components in hub are applied. + // Available: Components in hub are available and ready to serve. + // Progressing: Components in hub are in a transitioning state. + // Degraded: Components in hub do not match the desired configuration and only provide + // degraded service. + Conditions []metav1.Condition `json:"conditions"` + + // Generations are used to determine when an item needs to be reconciled or has changed in a way that needs a reaction. + // +optional + Generations []GenerationStatus `json:"generations,omitempty"` + + // RelatedResources are used to track the resources that are related to this ClusterManager. + // +optional + RelatedResources []RelatedResourceMeta `json:"relatedResources,omitempty"` +} + +// RelatedResourceMeta represents the resource that is managed by an operator +type RelatedResourceMeta struct { + // group is the group of the resource that you're tracking + // +required + Group string `json:"group"` + + // version is the version of the thing you're tracking + // +required + Version string `json:"version"` + + // resource is the resource type of the resource that you're tracking + // +required + Resource string `json:"resource"` + + // namespace is where the thing you're tracking is + // +optional + Namespace string `json:"namespace"` + + // name is the name of the resource that you're tracking + // +required + Name string `json:"name"` +} + +// GenerationStatus keeps track of the generation for a given resource so that decisions about forced updates can be made. +// The definition matches the GenerationStatus defined in github.com/openshift/api/v1 +type GenerationStatus struct { + // group is the group of the resource that you're tracking + // +required + Group string `json:"group"` + + // version is the version of the resource that you're tracking + // +required + Version string `json:"version"` + + // resource is the resource type of the resource that you're tracking + // +required + Resource string `json:"resource"` + + // namespace is where the resource that you're tracking is + // +optional + Namespace string `json:"namespace"` + + // name is the name of the resource that you're tracking + // +required + Name string `json:"name"` + + // lastGeneration is the last generation of the resource that controller applies + // +required + LastGeneration int64 `json:"lastGeneration" protobuf:"varint,5,opt,name=lastGeneration"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ClusterManagerList is a collection of deployment configurations for registration and work distribution controllers. +type ClusterManagerList struct { + metav1.TypeMeta `json:",inline"` + // Standard list metadata. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + + // Items is a list of deployment configurations for registration and work distribution controllers. + Items []ClusterManager `json:"items"` +} + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:subresource:status +// +kubebuilder:resource:scope=Cluster + +// Klusterlet represents controllers to install the resources for a managed cluster. +// When configured, the Klusterlet requires a secret named bootstrap-hub-kubeconfig in the +// agent namespace to allow API requests to the hub for the registration protocol. +// In Hosted mode, the Klusterlet requires an additional secret named external-managed-kubeconfig +// in the agent namespace to allow API requests to the managed cluster for resources installation. +type Klusterlet struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec represents the desired deployment configuration of Klusterlet agent. + Spec KlusterletSpec `json:"spec,omitempty"` + + // Status represents the current status of Klusterlet agent. + Status KlusterletStatus `json:"status,omitempty"` +} + +// KlusterletSpec represents the desired deployment configuration of Klusterlet agent. +type KlusterletSpec struct { + // Namespace is the namespace to deploy the agent on the managed cluster. + // The namespace must have a prefix of "open-cluster-management-", and if it is not set, + // the namespace of "open-cluster-management-agent" is used to deploy agent. + // In addition, the add-ons are deployed to the namespace of "{Namespace}-addon". + // In the Hosted mode, this namespace still exists on the managed cluster to contain + // necessary resources, like service accounts, roles and rolebindings, while the agent + // is deployed to the namespace with the same name as klusterlet on the management cluster. + // +optional + // +kubebuilder:validation:MaxLength=63 + // +kubebuilder:validation:Pattern=^open-cluster-management-[-a-z0-9]*[a-z0-9]$ + Namespace string `json:"namespace,omitempty"` + + // RegistrationImagePullSpec represents the desired image configuration of registration agent. + // quay.io/open-cluster-management.io/registration:latest will be used if unspecified. + // +optional + RegistrationImagePullSpec string `json:"registrationImagePullSpec,omitempty"` + + // WorkImagePullSpec represents the desired image configuration of work agent. + // quay.io/open-cluster-management.io/work:latest will be used if unspecified. + // +optional + WorkImagePullSpec string `json:"workImagePullSpec,omitempty"` + + // ClusterName is the name of the managed cluster to be created on hub. + // The Klusterlet agent generates a random name if it is not set, or discovers the appropriate cluster name on OpenShift. + // +optional + ClusterName string `json:"clusterName,omitempty"` + + // ExternalServerURLs represents the a list of apiserver urls and ca bundles that is accessible externally + // If it is set empty, managed cluster has no externally accessible url that hub cluster can visit. + // +optional + ExternalServerURLs []ServerURL `json:"externalServerURLs,omitempty"` + + // NodePlacement enables explicit control over the scheduling of the deployed pods. + // +optional + NodePlacement NodePlacement `json:"nodePlacement,omitempty"` + + // DeployOption contains the options of deploying a klusterlet + // +optional + DeployOption KlusterletDeployOption `json:"deployOption,omitempty"` + + // RegistrationConfiguration contains the configuration of registration + // +optional + RegistrationConfiguration *RegistrationConfiguration `json:"registrationConfiguration,omitempty"` + + // HubApiServerHostAlias contains the host alias for hub api server. + // registration-agent and work-agent will use it to communicate with hub api server. + // +optional + HubApiServerHostAlias *HubApiServerHostAlias `json:"hubApiServerHostAlias,omitempty"` +} + +// ServerURL represents the apiserver url and ca bundle that is accessible externally +type ServerURL struct { + // URL is the url of apiserver endpoint of the managed cluster. + // +required + URL string `json:"url"` + + // CABundle is the ca bundle to connect to apiserver of the managed cluster. + // System certs are used if it is not set. + // +optional + CABundle []byte `json:"caBundle,omitempty"` +} + +// NodePlacement describes node scheduling configuration for the pods. +type NodePlacement struct { + // NodeSelector defines which Nodes the Pods are scheduled on. The default is an empty list. + // +optional + NodeSelector map[string]string `json:"nodeSelector,omitempty"` + + // Tolerations is attached by pods to tolerate any taint that matches + // the triple using the matching operator . + // The default is an empty list. + // +optional + Tolerations []v1.Toleration `json:"tolerations,omitempty"` +} + +// HubApiServerHostAlias holds the mapping between IP and hostname that will be injected as an entry in the +// pod's hosts file. +type HubApiServerHostAlias struct { + // IP address of the host file entry. + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:Pattern=`^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$` + IP string `json:"ip"` + + // Hostname for the above IP address. + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:Pattern=`^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$` + Hostname string `json:"hostname"` +} + +// KlusterletStatus represents the current status of Klusterlet agent. +type KlusterletStatus struct { + // ObservedGeneration is the last generation change you've dealt with + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` + + // Conditions contain the different condition statuses for this Klusterlet. + // Valid condition types are: + // Applied: Components have been applied in the managed cluster. + // Available: Components in the managed cluster are available and ready to serve. + // Progressing: Components in the managed cluster are in a transitioning state. + // Degraded: Components in the managed cluster do not match the desired configuration and only provide + // degraded service. + Conditions []metav1.Condition `json:"conditions"` + + // Generations are used to determine when an item needs to be reconciled or has changed in a way that needs a reaction. + // +optional + Generations []GenerationStatus `json:"generations,omitempty"` + + // RelatedResources are used to track the resources that are related to this Klusterlet. + // +optional + RelatedResources []RelatedResourceMeta `json:"relatedResources,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// KlusterletList is a collection of Klusterlet agents. +type KlusterletList struct { + metav1.TypeMeta `json:",inline"` + // Standard list metadata. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + + // Items is a list of Klusterlet agents. + Items []Klusterlet `json:"items"` +} diff --git a/vendor/open-cluster-management.io/api/operator/v1/zz_generated.deepcopy.go b/vendor/open-cluster-management.io/api/operator/v1/zz_generated.deepcopy.go new file mode 100644 index 00000000..3bfaba4d --- /dev/null +++ b/vendor/open-cluster-management.io/api/operator/v1/zz_generated.deepcopy.go @@ -0,0 +1,465 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterManager) DeepCopyInto(out *ClusterManager) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterManager. +func (in *ClusterManager) DeepCopy() *ClusterManager { + if in == nil { + return nil + } + out := new(ClusterManager) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterManager) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterManagerDeployOption) DeepCopyInto(out *ClusterManagerDeployOption) { + *out = *in + if in.Hosted != nil { + in, out := &in.Hosted, &out.Hosted + *out = new(HostedClusterManagerConfiguration) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterManagerDeployOption. +func (in *ClusterManagerDeployOption) DeepCopy() *ClusterManagerDeployOption { + if in == nil { + return nil + } + out := new(ClusterManagerDeployOption) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterManagerList) DeepCopyInto(out *ClusterManagerList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ClusterManager, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterManagerList. +func (in *ClusterManagerList) DeepCopy() *ClusterManagerList { + if in == nil { + return nil + } + out := new(ClusterManagerList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterManagerList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterManagerSpec) DeepCopyInto(out *ClusterManagerSpec) { + *out = *in + in.NodePlacement.DeepCopyInto(&out.NodePlacement) + in.DeployOption.DeepCopyInto(&out.DeployOption) + if in.RegistrationConfiguration != nil { + in, out := &in.RegistrationConfiguration, &out.RegistrationConfiguration + *out = new(RegistrationConfiguration) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterManagerSpec. +func (in *ClusterManagerSpec) DeepCopy() *ClusterManagerSpec { + if in == nil { + return nil + } + out := new(ClusterManagerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterManagerStatus) DeepCopyInto(out *ClusterManagerStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]metav1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Generations != nil { + in, out := &in.Generations, &out.Generations + *out = make([]GenerationStatus, len(*in)) + copy(*out, *in) + } + if in.RelatedResources != nil { + in, out := &in.RelatedResources, &out.RelatedResources + *out = make([]RelatedResourceMeta, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterManagerStatus. +func (in *ClusterManagerStatus) DeepCopy() *ClusterManagerStatus { + if in == nil { + return nil + } + out := new(ClusterManagerStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FeatureGate) DeepCopyInto(out *FeatureGate) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FeatureGate. +func (in *FeatureGate) DeepCopy() *FeatureGate { + if in == nil { + return nil + } + out := new(FeatureGate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GenerationStatus) DeepCopyInto(out *GenerationStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenerationStatus. +func (in *GenerationStatus) DeepCopy() *GenerationStatus { + if in == nil { + return nil + } + out := new(GenerationStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HostedClusterManagerConfiguration) DeepCopyInto(out *HostedClusterManagerConfiguration) { + *out = *in + out.RegistrationWebhookConfiguration = in.RegistrationWebhookConfiguration + out.WorkWebhookConfiguration = in.WorkWebhookConfiguration + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostedClusterManagerConfiguration. +func (in *HostedClusterManagerConfiguration) DeepCopy() *HostedClusterManagerConfiguration { + if in == nil { + return nil + } + out := new(HostedClusterManagerConfiguration) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HubApiServerHostAlias) DeepCopyInto(out *HubApiServerHostAlias) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HubApiServerHostAlias. +func (in *HubApiServerHostAlias) DeepCopy() *HubApiServerHostAlias { + if in == nil { + return nil + } + out := new(HubApiServerHostAlias) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Klusterlet) DeepCopyInto(out *Klusterlet) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Klusterlet. +func (in *Klusterlet) DeepCopy() *Klusterlet { + if in == nil { + return nil + } + out := new(Klusterlet) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Klusterlet) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KlusterletDeployOption) DeepCopyInto(out *KlusterletDeployOption) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KlusterletDeployOption. +func (in *KlusterletDeployOption) DeepCopy() *KlusterletDeployOption { + if in == nil { + return nil + } + out := new(KlusterletDeployOption) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KlusterletList) DeepCopyInto(out *KlusterletList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Klusterlet, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KlusterletList. +func (in *KlusterletList) DeepCopy() *KlusterletList { + if in == nil { + return nil + } + out := new(KlusterletList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KlusterletList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KlusterletSpec) DeepCopyInto(out *KlusterletSpec) { + *out = *in + if in.ExternalServerURLs != nil { + in, out := &in.ExternalServerURLs, &out.ExternalServerURLs + *out = make([]ServerURL, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + in.NodePlacement.DeepCopyInto(&out.NodePlacement) + out.DeployOption = in.DeployOption + if in.RegistrationConfiguration != nil { + in, out := &in.RegistrationConfiguration, &out.RegistrationConfiguration + *out = new(RegistrationConfiguration) + (*in).DeepCopyInto(*out) + } + if in.HubApiServerHostAlias != nil { + in, out := &in.HubApiServerHostAlias, &out.HubApiServerHostAlias + *out = new(HubApiServerHostAlias) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KlusterletSpec. +func (in *KlusterletSpec) DeepCopy() *KlusterletSpec { + if in == nil { + return nil + } + out := new(KlusterletSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KlusterletStatus) DeepCopyInto(out *KlusterletStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]metav1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Generations != nil { + in, out := &in.Generations, &out.Generations + *out = make([]GenerationStatus, len(*in)) + copy(*out, *in) + } + if in.RelatedResources != nil { + in, out := &in.RelatedResources, &out.RelatedResources + *out = make([]RelatedResourceMeta, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KlusterletStatus. +func (in *KlusterletStatus) DeepCopy() *KlusterletStatus { + if in == nil { + return nil + } + out := new(KlusterletStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodePlacement) DeepCopyInto(out *NodePlacement) { + *out = *in + if in.NodeSelector != nil { + in, out := &in.NodeSelector, &out.NodeSelector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Tolerations != nil { + in, out := &in.Tolerations, &out.Tolerations + *out = make([]corev1.Toleration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodePlacement. +func (in *NodePlacement) DeepCopy() *NodePlacement { + if in == nil { + return nil + } + out := new(NodePlacement) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RegistrationConfiguration) DeepCopyInto(out *RegistrationConfiguration) { + *out = *in + if in.FeatureGates != nil { + in, out := &in.FeatureGates, &out.FeatureGates + *out = make([]FeatureGate, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RegistrationConfiguration. +func (in *RegistrationConfiguration) DeepCopy() *RegistrationConfiguration { + if in == nil { + return nil + } + out := new(RegistrationConfiguration) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RelatedResourceMeta) DeepCopyInto(out *RelatedResourceMeta) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RelatedResourceMeta. +func (in *RelatedResourceMeta) DeepCopy() *RelatedResourceMeta { + if in == nil { + return nil + } + out := new(RelatedResourceMeta) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServerURL) DeepCopyInto(out *ServerURL) { + *out = *in + if in.CABundle != nil { + in, out := &in.CABundle, &out.CABundle + *out = make([]byte, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServerURL. +func (in *ServerURL) DeepCopy() *ServerURL { + if in == nil { + return nil + } + out := new(ServerURL) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WebhookConfiguration) DeepCopyInto(out *WebhookConfiguration) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WebhookConfiguration. +func (in *WebhookConfiguration) DeepCopy() *WebhookConfiguration { + if in == nil { + return nil + } + out := new(WebhookConfiguration) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/open-cluster-management.io/api/operator/v1/zz_generated.swagger_doc_generated.go b/vendor/open-cluster-management.io/api/operator/v1/zz_generated.swagger_doc_generated.go new file mode 100644 index 00000000..0beb00c5 --- /dev/null +++ b/vendor/open-cluster-management.io/api/operator/v1/zz_generated.swagger_doc_generated.go @@ -0,0 +1,222 @@ +package v1 + +// This file contains a collection of methods that can be used from go-restful to +// generate Swagger API documentation for its models. Please read this PR for more +// information on the implementation: https://github.com/emicklei/go-restful/pull/215 +// +// TODOs are ignored from the parser (e.g. TODO(andronat):... || TODO:...) if and only if +// they are on one line! For multiple line or blocks that you want to ignore use ---. +// Any context after a --- is ignored. +// +// Those methods can be generated by using hack/update-swagger-docs.sh + +// AUTO-GENERATED FUNCTIONS START HERE +var map_ClusterManager = map[string]string{ + "": "ClusterManager configures the controllers on the hub that govern registration and work distribution for attached Klusterlets. In Default mode, ClusterManager will only be deployed in open-cluster-management-hub namespace. In Hosted mode, ClusterManager will be deployed in the namespace with the same name as cluster manager.", + "spec": "Spec represents a desired deployment configuration of controllers that govern registration and work distribution for attached Klusterlets.", + "status": "Status represents the current status of controllers that govern the lifecycle of managed clusters.", +} + +func (ClusterManager) SwaggerDoc() map[string]string { + return map_ClusterManager +} + +var map_ClusterManagerDeployOption = map[string]string{ + "": "ClusterManagerDeployOption describes the deploy options for cluster-manager", + "mode": "Mode can be Default or Hosted. In Default mode, the Hub is installed as a whole and all parts of Hub are deployed in the same cluster. In Hosted mode, only crd and configurations are installed on one cluster(defined as hub-cluster). Controllers run in another cluster (defined as management-cluster) and connect to the hub with the kubeconfig in secret of \"external-hub-kubeconfig\"(a kubeconfig of hub-cluster with cluster-admin permission). Note: Do not modify the Mode field once it's applied.", + "hosted": "Hosted includes configurations we needs for clustermanager in the Hosted mode.", +} + +func (ClusterManagerDeployOption) SwaggerDoc() map[string]string { + return map_ClusterManagerDeployOption +} + +var map_ClusterManagerList = map[string]string{ + "": "ClusterManagerList is a collection of deployment configurations for registration and work distribution controllers.", + "metadata": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "items": "Items is a list of deployment configurations for registration and work distribution controllers.", +} + +func (ClusterManagerList) SwaggerDoc() map[string]string { + return map_ClusterManagerList +} + +var map_ClusterManagerSpec = map[string]string{ + "": "ClusterManagerSpec represents a desired deployment configuration of controllers that govern registration and work distribution for attached Klusterlets.", + "registrationImagePullSpec": "RegistrationImagePullSpec represents the desired image of registration controller/webhook installed on hub.", + "workImagePullSpec": "WorkImagePullSpec represents the desired image configuration of work controller/webhook installed on hub.", + "placementImagePullSpec": "PlacementImagePullSpec represents the desired image configuration of placement controller/webhook installed on hub.", + "nodePlacement": "NodePlacement enables explicit control over the scheduling of the deployed pods.", + "deployOption": "DeployOption contains the options of deploying a cluster-manager Default mode is used if DeployOption is not set.", + "registrationConfiguration": "RegistrationConfiguration contains the configuration of registration", +} + +func (ClusterManagerSpec) SwaggerDoc() map[string]string { + return map_ClusterManagerSpec +} + +var map_ClusterManagerStatus = map[string]string{ + "": "ClusterManagerStatus represents the current status of the registration and work distribution controllers running on the hub.", + "observedGeneration": "ObservedGeneration is the last generation change you've dealt with", + "conditions": "Conditions contain the different condition statuses for this ClusterManager. Valid condition types are: Applied: Components in hub are applied. Available: Components in hub are available and ready to serve. Progressing: Components in hub are in a transitioning state. Degraded: Components in hub do not match the desired configuration and only provide degraded service.", + "generations": "Generations are used to determine when an item needs to be reconciled or has changed in a way that needs a reaction.", + "relatedResources": "RelatedResources are used to track the resources that are related to this ClusterManager.", +} + +func (ClusterManagerStatus) SwaggerDoc() map[string]string { + return map_ClusterManagerStatus +} + +var map_FeatureGate = map[string]string{ + "feature": "Feature is the key of feature gate. e.g. featuregate/Foo.", + "mode": "Mode is either Enable, Disable, \"\" where \"\" is Disable by default. In Enable mode, a valid feature gate `featuregate/Foo` will be set to \"--featuregate/Foo=true\". In Disable mode, a valid feature gate `featuregate/Foo` will be set to \"--featuregate/Foo=false\".", +} + +func (FeatureGate) SwaggerDoc() map[string]string { + return map_FeatureGate +} + +var map_GenerationStatus = map[string]string{ + "": "GenerationStatus keeps track of the generation for a given resource so that decisions about forced updates can be made. The definition matches the GenerationStatus defined in github.com/openshift/api/v1", + "group": "group is the group of the resource that you're tracking", + "version": "version is the version of the resource that you're tracking", + "resource": "resource is the resource type of the resource that you're tracking", + "namespace": "namespace is where the resource that you're tracking is", + "name": "name is the name of the resource that you're tracking", + "lastGeneration": "lastGeneration is the last generation of the resource that controller applies", +} + +func (GenerationStatus) SwaggerDoc() map[string]string { + return map_GenerationStatus +} + +var map_HostedClusterManagerConfiguration = map[string]string{ + "": "HostedClusterManagerConfiguration represents customized configurations we need to set for clustermanager in the Hosted mode.", + "registrationWebhookConfiguration": "RegistrationWebhookConfiguration represents the customized webhook-server configuration of registration.", + "workWebhookConfiguration": "WorkWebhookConfiguration represents the customized webhook-server configuration of work.", +} + +func (HostedClusterManagerConfiguration) SwaggerDoc() map[string]string { + return map_HostedClusterManagerConfiguration +} + +var map_HubApiServerHostAlias = map[string]string{ + "": "HubApiServerHostAlias holds the mapping between IP and hostname that will be injected as an entry in the pod's hosts file.", + "ip": "IP address of the host file entry.", + "hostname": "Hostname for the above IP address.", +} + +func (HubApiServerHostAlias) SwaggerDoc() map[string]string { + return map_HubApiServerHostAlias +} + +var map_Klusterlet = map[string]string{ + "": "Klusterlet represents controllers to install the resources for a managed cluster. When configured, the Klusterlet requires a secret named bootstrap-hub-kubeconfig in the agent namespace to allow API requests to the hub for the registration protocol. In Hosted mode, the Klusterlet requires an additional secret named external-managed-kubeconfig in the agent namespace to allow API requests to the managed cluster for resources installation.", + "spec": "Spec represents the desired deployment configuration of Klusterlet agent.", + "status": "Status represents the current status of Klusterlet agent.", +} + +func (Klusterlet) SwaggerDoc() map[string]string { + return map_Klusterlet +} + +var map_KlusterletDeployOption = map[string]string{ + "": "KlusterletDeployOption describes the deploy options for klusterlet", + "mode": "Mode can be Default or Hosted. It is Default mode if not specified In Default mode, all klusterlet related resources are deployed on the managed cluster. In Hosted mode, only crd and configurations are installed on the spoke/managed cluster. Controllers run in another cluster (defined as management-cluster) and connect to the mangaged cluster with the kubeconfig in secret of \"external-managed-kubeconfig\"(a kubeconfig of managed-cluster with cluster-admin permission). Note: Do not modify the Mode field once it's applied.", +} + +func (KlusterletDeployOption) SwaggerDoc() map[string]string { + return map_KlusterletDeployOption +} + +var map_KlusterletList = map[string]string{ + "": "KlusterletList is a collection of Klusterlet agents.", + "metadata": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "items": "Items is a list of Klusterlet agents.", +} + +func (KlusterletList) SwaggerDoc() map[string]string { + return map_KlusterletList +} + +var map_KlusterletSpec = map[string]string{ + "": "KlusterletSpec represents the desired deployment configuration of Klusterlet agent.", + "namespace": "Namespace is the namespace to deploy the agent on the managed cluster. The namespace must have a prefix of \"open-cluster-management-\", and if it is not set, the namespace of \"open-cluster-management-agent\" is used to deploy agent. In addition, the add-ons are deployed to the namespace of \"{Namespace}-addon\". In the Hosted mode, this namespace still exists on the managed cluster to contain necessary resources, like service accounts, roles and rolebindings, while the agent is deployed to the namespace with the same name as klusterlet on the management cluster.", + "registrationImagePullSpec": "RegistrationImagePullSpec represents the desired image configuration of registration agent. quay.io/open-cluster-management.io/registration:latest will be used if unspecified.", + "workImagePullSpec": "WorkImagePullSpec represents the desired image configuration of work agent. quay.io/open-cluster-management.io/work:latest will be used if unspecified.", + "clusterName": "ClusterName is the name of the managed cluster to be created on hub. The Klusterlet agent generates a random name if it is not set, or discovers the appropriate cluster name on OpenShift.", + "externalServerURLs": "ExternalServerURLs represents the a list of apiserver urls and ca bundles that is accessible externally If it is set empty, managed cluster has no externally accessible url that hub cluster can visit.", + "nodePlacement": "NodePlacement enables explicit control over the scheduling of the deployed pods.", + "deployOption": "DeployOption contains the options of deploying a klusterlet", + "registrationConfiguration": "RegistrationConfiguration contains the configuration of registration", + "hubApiServerHostAlias": "HubApiServerHostAlias contains the host alias for hub api server. registration-agent and work-agent will use it to communicate with hub api server.", +} + +func (KlusterletSpec) SwaggerDoc() map[string]string { + return map_KlusterletSpec +} + +var map_KlusterletStatus = map[string]string{ + "": "KlusterletStatus represents the current status of Klusterlet agent.", + "observedGeneration": "ObservedGeneration is the last generation change you've dealt with", + "conditions": "Conditions contain the different condition statuses for this Klusterlet. Valid condition types are: Applied: Components have been applied in the managed cluster. Available: Components in the managed cluster are available and ready to serve. Progressing: Components in the managed cluster are in a transitioning state. Degraded: Components in the managed cluster do not match the desired configuration and only provide degraded service.", + "generations": "Generations are used to determine when an item needs to be reconciled or has changed in a way that needs a reaction.", + "relatedResources": "RelatedResources are used to track the resources that are related to this Klusterlet.", +} + +func (KlusterletStatus) SwaggerDoc() map[string]string { + return map_KlusterletStatus +} + +var map_NodePlacement = map[string]string{ + "": "NodePlacement describes node scheduling configuration for the pods.", + "nodeSelector": "NodeSelector defines which Nodes the Pods are scheduled on. The default is an empty list.", + "tolerations": "Tolerations is attached by pods to tolerate any taint that matches the triple using the matching operator . The default is an empty list.", +} + +func (NodePlacement) SwaggerDoc() map[string]string { + return map_NodePlacement +} + +var map_RegistrationConfiguration = map[string]string{ + "featureGates": "FeatureGates represents the list of feature gates for registration If it is set empty, default feature gates will be used. If it is set, featuregate/Foo is an example of one item in FeatureGates:\n 1. If featuregate/Foo does not exist, registration-operator will discard it\n 2. If featuregate/Foo exists and is false by default. It is now possible to set featuregate/Foo=[false|true]\n 3. If featuregate/Foo exists and is true by default. If a cluster-admin upgrading from 1 to 2 wants to continue having featuregate/Foo=false,\n \the can set featuregate/Foo=false before upgrading. Let's say the cluster-admin wants featuregate/Foo=false.", +} + +func (RegistrationConfiguration) SwaggerDoc() map[string]string { + return map_RegistrationConfiguration +} + +var map_RelatedResourceMeta = map[string]string{ + "": "RelatedResourceMeta represents the resource that is managed by an operator", + "group": "group is the group of the resource that you're tracking", + "version": "version is the version of the thing you're tracking", + "resource": "resource is the resource type of the resource that you're tracking", + "namespace": "namespace is where the thing you're tracking is", + "name": "name is the name of the resource that you're tracking", +} + +func (RelatedResourceMeta) SwaggerDoc() map[string]string { + return map_RelatedResourceMeta +} + +var map_ServerURL = map[string]string{ + "": "ServerURL represents the apiserver url and ca bundle that is accessible externally", + "url": "URL is the url of apiserver endpoint of the managed cluster.", + "caBundle": "CABundle is the ca bundle to connect to apiserver of the managed cluster. System certs are used if it is not set.", +} + +func (ServerURL) SwaggerDoc() map[string]string { + return map_ServerURL +} + +var map_WebhookConfiguration = map[string]string{ + "": "WebhookConfiguration has two properties: Address and Port.", + "address": "Address represents the address of a webhook-server. It could be in IP format or fqdn format. The Address must be reachable by apiserver of the hub cluster.", + "port": "Port represents the port of a webhook-server. The default value of Port is 443.", +} + +func (WebhookConfiguration) SwaggerDoc() map[string]string { + return map_WebhookConfiguration +} + +// AUTO-GENERATED FUNCTIONS END HERE