Skip to content

Commit

Permalink
Update Services Status for ManagedCluster & MultiClusterService
Browse files Browse the repository at this point in the history
  • Loading branch information
wahabmk committed Oct 24, 2024
1 parent 59a0e13 commit 1f2245c
Show file tree
Hide file tree
Showing 15 changed files with 823 additions and 28 deletions.
11 changes: 11 additions & 0 deletions api/v1alpha1/managedcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ const (
HelmReleaseReadyCondition = "HelmReleaseReady"
// ReadyCondition indicates the ManagedCluster is ready and fully reconciled.
ReadyCondition string = "Ready"

SveltosProfileCondition = "SveltosProfileReady"
SveltosClusterProfileCondition = "SveltosClusterProfileReady"
)

// ManagedClusterSpec defines the desired state of ManagedCluster
Expand Down Expand Up @@ -92,6 +95,8 @@ type ManagedClusterSpec struct {

// ManagedClusterStatus defines the observed state of ManagedCluster
type ManagedClusterStatus struct {
Services []ServicesStatus `json:"services,omitempty"`
// Services []*apiextensionsv1.JSON `json:"services,omitempty"`
// Currently compatible exact Kubernetes version of the cluster. Being set only if
// provided by the corresponding ClusterTemplate.
KubernetesVersion string `json:"k8sVersion,omitempty"`
Expand All @@ -101,6 +106,12 @@ type ManagedClusterStatus struct {
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

type ServicesStatus struct {
ClusterName string `json:"clusterName"`
ClusterNamespace string `json:"clusterNamespace,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:shortName=mcluster;mcl
Expand Down
11 changes: 9 additions & 2 deletions api/v1alpha1/multiclusterservice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@ type MultiClusterServiceSpec struct {
// If this status ends up being common with ManagedClusterStatus,
// then make a common status struct that can be shared by both.
type MultiClusterServiceStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
Services []ServicesStatus `json:"services,omitempty"`
// Conditions contains details for the current state of the ManagedCluster
Conditions []metav1.Condition `json:"conditions,omitempty"`
// ObservedGeneration is the last observed generation.
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

// +kubebuilder:object:root=true
Expand All @@ -106,6 +109,10 @@ type MultiClusterServiceList struct {
Items []MultiClusterService `json:"items"`
}

func (in *MultiClusterService) GetConditions() *[]metav1.Condition {
return &in.Status.Conditions
}

func init() {
SchemeBuilder.Register(&MultiClusterService{}, &MultiClusterServiceList{})
}
45 changes: 44 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

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

51 changes: 51 additions & 0 deletions clusterconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright 2024
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: config.projectsveltos.io/v1beta1
kind: ClusterConfiguration
metadata:
creationTimestamp: "2024-10-18T02:00:50Z"
generation: 1
labels:
projectsveltos.io/cluster-name: wali-aws-dev
projectsveltos.io/cluster-type: Capi
name: capi--wali-aws-dev
namespace: hmc-system
ownerReferences:
- apiVersion: config.projectsveltos.io/v1beta1
kind: Profile
name: wali-aws-dev
uid: 29c6d683-cecd-4554-abd6-ffe50ca3e557
resourceVersion: "9110"
uid: 7fed8bcf-1202-4fce-8cd3-a840359ce693
status:
profileResources:
- Features:
- charts:
- appVersion: v1.12.5
chartVersion: 3.2.6
lastAppliedTime: "2024-10-18T02:02:28Z"
namespace: kyverno
releaseName: kyverno
repoURL: oci://hmc-local-registry:5000/charts
- appVersion: 1.11.0
chartVersion: 4.11.0
lastAppliedTime: "2024-10-18T02:07:50Z"
namespace: ingress-nginx
releaseName: ingress-nginx
repoURL: oci://hmc-local-registry:5000/charts
featureID: Helm
- featureID: Kustomize
- featureID: Resources
profileName: wali-aws-dev
92 changes: 92 additions & 0 deletions clustersummary.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Copyright 2024
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: config.projectsveltos.io/v1beta1
kind: ClusterSummary
metadata:
creationTimestamp: "2024-10-18T02:00:51Z"
deletionGracePeriodSeconds: 0
deletionTimestamp: "2024-10-18T02:11:42Z"
finalizers:
- clustersummaryfinalizer.projectsveltos.io
generation: 2
labels:
hmc.mirantis.com/managed: "true"
projectsveltos.io/cluster-name: wali-aws-dev
projectsveltos.io/cluster-type: Capi
projectsveltos.io/profile-name: wali-aws-dev
name: p--wali-aws-dev-capi-wali-aws-dev
namespace: hmc-system
ownerReferences:
- apiVersion: config.projectsveltos.io/v1beta1
kind: Profile
name: wali-aws-dev
uid: 29c6d683-cecd-4554-abd6-ffe50ca3e557
resourceVersion: "9108"
uid: 09ea1572-bff1-4e81-9202-d84fcf739dba
spec:
clusterName: wali-aws-dev
clusterNamespace: hmc-system
clusterProfileSpec:
clusterSelector:
matchLabels:
helm.toolkit.fluxcd.io/name: wali-aws-dev
helm.toolkit.fluxcd.io/namespace: hmc-system
continueOnConflict: true
helmCharts:
- chartName: kyverno
chartVersion: 3.2.6
helmChartAction: Install
registryCredentialsConfig:
plainHTTP: true
releaseName: kyverno
releaseNamespace: kyverno
repositoryName: kyverno
repositoryURL: oci://hmc-local-registry:5000/charts
- chartName: ingress-nginx
chartVersion: 4.11.0
helmChartAction: Install
registryCredentialsConfig:
plainHTTP: true
releaseName: ingress-nginx
releaseNamespace: ingress-nginx
repositoryName: ingress-nginx
repositoryURL: oci://hmc-local-registry:5000/charts
reloader: false
stopMatchingBehavior: WithdrawPolicies
syncMode: Continuous
tier: 2147483547
clusterType: Capi
status:
dependencies: no dependencies
featureSummaries:
- failureMessage: cluster is marked for deletion.
featureID: Helm
lastAppliedTime: "2024-10-18T02:11:42Z"
status: Failed
- featureID: Resources
lastAppliedTime: "2024-10-18T02:11:42Z"
status: Removing
- featureID: Kustomize
lastAppliedTime: "2024-10-18T02:11:42Z"
status: Removing
helmReleaseSummaries:
- releaseName: kyverno
releaseNamespace: kyverno
status: Managing
valuesHash: Eq4yyx7ALQHto1gbEnwf7jsNxTVy7WuvI5choD2C4SY=
- releaseName: ingress-nginx
releaseNamespace: ingress-nginx
status: Managing
valuesHash: Eq4yyx7ALQHto1gbEnwf7jsNxTVy7WuvI5choD2C4SY=
57 changes: 57 additions & 0 deletions clustersummary_apply.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2024
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: config.projectsveltos.io/v1beta1
kind: ClusterSummary
metadata:
labels:
hmc.mirantis.com/managed: "true"
projectsveltos.io/cluster-name: wali-aws-dev
projectsveltos.io/cluster-type: Capi
projectsveltos.io/profile-name: wali-aws-dev
name: p--wali-aws-dev-capi-wali-aws-dev
namespace: hmc-system
spec:
clusterName: wali-aws-dev
clusterNamespace: hmc-system
clusterProfileSpec:
clusterSelector:
matchLabels:
helm.toolkit.fluxcd.io/name: wali-aws-dev
helm.toolkit.fluxcd.io/namespace: hmc-system
continueOnConflict: true
helmCharts:
- chartName: kyverno
chartVersion: 3.2.6
helmChartAction: Install
registryCredentialsConfig:
plainHTTP: true
releaseName: kyverno
releaseNamespace: kyverno
repositoryName: kyverno
repositoryURL: oci://hmc-local-registry:5000/charts
- chartName: ingress-nginx
chartVersion: 4.11.0
helmChartAction: Install
registryCredentialsConfig:
plainHTTP: true
releaseName: ingress-nginx
releaseNamespace: ingress-nginx
repositoryName: ingress-nginx
repositoryURL: oci://hmc-local-registry:5000/charts
reloader: false
stopMatchingBehavior: WithdrawPolicies
syncMode: Continuous
tier: 2147483547
clusterType: Capi
6 changes: 4 additions & 2 deletions config/dev/aws-managedcluster.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: hmc.mirantis.com/v1alpha1
kind: ManagedCluster
metadata:
name: aws-dev
name: wali-aws-dev
namespace: ${NAMESPACE}
spec:
credential: aws-cluster-identity-cred
Expand All @@ -10,11 +10,13 @@ spec:
name: aws-cluster-identity
namespace: ${NAMESPACE}
controlPlane:
amiID: ami-0eb9fdcf0d07bd5ef
instanceType: t3.small
controlPlaneNumber: 1
publicIP: true
region: us-west-2
region: ca-central-1
worker:
amiID: ami-0eb9fdcf0d07bd5ef
instanceType: t3.small
workersNumber: 1
template: aws-standalone-cp-0-0-2
Expand Down
Loading

0 comments on commit 1f2245c

Please sign in to comment.