Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update Services Status for ManagedCluster & MultiClusterService #550

Merged
merged 2 commits into from
Nov 7, 2024

Conversation

wahabmk
Copy link
Contributor

@wahabmk wahabmk commented Oct 24, 2024

Description

This PR adds status for services deployment to ManagedCluster and MultiClusterService objects.

Examples

Deploy 1 ManagedCluster

The following table shows the status of a ManagedCluster object alongside with the status of its associated Sveltos ClusterSummary object. The ClusterSummary -> is owned by Profile -> is owned by ManagedCluster.

ManagedCluster Status Sveltos ClusterSummary Status
apiVersion: hmc.mirantis.com/v1alpha1
kind: ManagedCluster
metadata:
  . . .
  generation: 1
  name: wali-aws-dev-1
  namespace: hmc-system
  resourceVersion: "19596"
  uid: 9d098f75-f049-4ecf-a131-c8830755fb10
spec:
  . . .
  services:
  - name: kyverno
    namespace: kyverno
    template: kyverno-3-2-6
  - name: ingress-nginx
    namespace: ingress-nginx
    template: ingress-nginx-4-11-0
  servicesPriority: 100
  stopOnConflict: false
  template: aws-standalone-cp-0-0-2
status:
  conditions:
  - lastTransitionTime: "2024-10-25T07:31:00Z"
    message: Template is valid
    reason: Succeeded
    status: "True"
    type: TemplateReady
  - lastTransitionTime: "2024-10-25T07:31:00Z"
    message: Helm chart is valid
    reason: Succeeded
    status: "True"
    type: HelmChartReady
  - lastTransitionTime: "2024-10-25T07:31:01Z"
    message: Helm install succeeded for release hmc-system/wali-aws-dev-1.v1 with
      chart [email protected]
    reason: InstallSucceeded
    status: "True"
    type: HelmReleaseReady
  - lastTransitionTime: "2024-10-25T07:36:31Z"
    message: ManagedCluster is ready
    reason: Succeeded
    status: "True"
    type: Ready
  - lastTransitionTime: "2024-10-25T07:31:00Z"
    message: Credential is Ready
    reason: Succeeded
    status: "True"
    type: CredentialReady
  - lastTransitionTime: "2024-10-25T07:36:31Z"
    message: ""
    reason: Succeeded
    status: "True"
    type: ControlPlaneInitialized
  - lastTransitionTime: "2024-10-25T07:36:31Z"
    message: ""
    reason: Succeeded
    status: "True"
    type: ControlPlaneReady
  - lastTransitionTime: "2024-10-25T07:34:40Z"
    message: ""
    reason: Succeeded
    status: "True"
    type: InfrastructureReady
  - lastTransitionTime: "2024-10-25T07:36:32Z"
    message: ""
    reason: Succeeded
    status: "True"
    type: SveltosProfileReady
  observedGeneration: 1
  services:
  - clusterName: wali-aws-dev-1
    clusterNamespace: hmc-system
    conditions:
    - lastTransitionTime: "2024-10-25T07:44:43Z"
      message: ""
      reason: Provisioned
      status: "True"
      type: Helm
    - lastTransitionTime: "2024-10-25T07:44:43Z"
      message: Release kyverno/kyverno
      reason: Managing
      status: "True"
      type: kyverno.kyverno/SveltosHelmReleaseReady
    - lastTransitionTime: "2024-10-25T07:44:43Z"
      message: Release ingress-nginx/ingress-nginx
      reason: Managing
      status: "True"
      type: ingress-nginx.ingress-nginx/SveltosHelmReleaseReady
apiVersion: config.projectsveltos.io/v1beta1
kind: ClusterSummary
metadata:
  creationTimestamp: "2024-10-25T07:36:33Z"
  finalizers:
  - clustersummaryfinalizer.projectsveltos.io
  generation: 1
  labels:
    hmc.mirantis.com/managed: "true"
    projectsveltos.io/cluster-name: wali-aws-dev-1
    projectsveltos.io/cluster-type: Capi
    projectsveltos.io/profile-name: wali-aws-dev-1
  name: p--wali-aws-dev-1-capi-wali-aws-dev-1
  namespace: hmc-system
  ownerReferences:
  - apiVersion: config.projectsveltos.io/v1beta1
    kind: Profile
    name: wali-aws-dev-1
    uid: bfe741dc-f361-455f-aabe-d224cc65688d
  resourceVersion: "19595"
  uid: 35e0e2c2-d21e-400f-a436-094c9f6c201e
spec:
  clusterName: wali-aws-dev-1
  clusterNamespace: hmc-system
  clusterProfileSpec:
    clusterSelector:
      matchLabels:
        helm.toolkit.fluxcd.io/name: wali-aws-dev-1
        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:
  - featureID: Helm
    hash: uCrU6dddLiLzhpCWUZ/hv7FZAv4V6KonpycS9uNjSNQ=
    lastAppliedTime: "2024-10-25T07:55:09Z"
    status: Provisioned
  helmReleaseSummaries:
  - releaseName: kyverno
    releaseNamespace: kyverno
    status: Managing
    valuesHash: Eq4yyx7ALQHto1gbEnwf7jsNxTVy7WuvI5choD2C4SY=
  - releaseName: ingress-nginx
    releaseNamespace: ingress-nginx
    status: Managing
    valuesHash: Eq4yyx7ALQHto1gbEnwf7jsNxTVy7WuvI5choD2C4SY=

Deploy 2 ManagedCluster and 1 MultiClusterService

I have the following:

  1. ManagedCluster wali-aws-dev-1 deploying kyverno and ingress-nginx with servicesPriority=100.
  2. ManagedCluster wali-aws-dev-2 deploying ingress-nginx with servicesPrriority=500.
  3. MultiClusterService global-nginx (matching both clusters) deploying ingress-nginx with servicesPriority=300.

So in the table below we should see the following in the status of these objects:

  1. ManagedCluster wali-aws-dev-1 should show conflict for ingress-nginx and a message indicating that it is being managed by another object. (I.e. ClusterSummary -> which has owner ClusterProfile -> which has the MultiClusterService global-nginx as its owner).
  2. ManagedCluster wali-aws-dev-2 should show no conflicts as it has the highest priority.
  3. MultiClusterService global-nginx should show no conflict with wali-aws-dev-1 (as it has higher priority than it) but should show a conflict with wali-aws-dev-2 (as it has lower priority than it)
ManagedCluster `wali-aws-dev-1` ManagedCluster `wali-aws-dev-2` MultiClusterService `global-nginx`
apiVersion: hmc.mirantis.com/v1alpha1
kind: ManagedCluster
metadata:
  . . . 
  generation: 1
  name: wali-aws-dev-1
  namespace: hmc-system
  resourceVersion: "37902"
  uid: 9d098f75-f049-4ecf-a131-c8830755fb10
spec:
  . . .
  services:
  - name: kyverno
    namespace: kyverno
    template: kyverno-3-2-6
  - name: ingress-nginx
    namespace: ingress-nginx
    template: ingress-nginx-4-11-0
  servicesPriority: 100
  stopOnConflict: false
  template: aws-standalone-cp-0-0-2
status:
  conditions:
  - lastTransitionTime: "2024-10-25T07:31:00Z"
    message: Template is valid
    reason: Succeeded
    status: "True"
    type: TemplateReady
  - lastTransitionTime: "2024-10-25T07:31:00Z"
    message: Helm chart is valid
    reason: Succeeded
    status: "True"
    type: HelmChartReady
  - lastTransitionTime: "2024-10-25T07:31:01Z"
    message: Helm install succeeded for release hmc-system/wali-aws-dev-1.v1 with
      chart [email protected]
    reason: InstallSucceeded
    status: "True"
    type: HelmReleaseReady
  - lastTransitionTime: "2024-10-25T07:36:31Z"
    message: ManagedCluster is ready
    reason: Succeeded
    status: "True"
    type: Ready
  - lastTransitionTime: "2024-10-25T07:31:00Z"
    message: Credential is Ready
    reason: Succeeded
    status: "True"
    type: CredentialReady
  - lastTransitionTime: "2024-10-25T07:36:31Z"
    message: ""
    reason: Succeeded
    status: "True"
    type: ControlPlaneInitialized
  - lastTransitionTime: "2024-10-25T07:36:31Z"
    message: ""
    reason: Succeeded
    status: "True"
    type: ControlPlaneReady
  - lastTransitionTime: "2024-10-25T07:34:40Z"
    message: ""
    reason: Succeeded
    status: "True"
    type: InfrastructureReady
  - lastTransitionTime: "2024-10-25T07:36:32Z"
    message: ""
    reason: Succeeded
    status: "True"
    type: SveltosProfileReady
  observedGeneration: 1
  services:
  - clusterName: wali-aws-dev-1
    clusterNamespace: hmc-system
    conditions:
    - lastTransitionTime: "2024-10-25T08:36:35Z"
      message: |
        cannot manage chart ingress-nginx/ingress-nginx. ClusterSummary global-ingress-capi-wali-aws-dev-1 managing it.
      reason: Provisioning
      status: "False"
      type: Helm
    - lastTransitionTime: "2024-10-25T07:44:43Z"
      message: Release kyverno/kyverno
      reason: Managing
      status: "True"
      type: kyverno.kyverno/SveltosHelmReleaseReady
    - lastTransitionTime: "2024-10-25T08:36:25Z"
      message: 'Release ingress-nginx/ingress-nginx: ClusterSummary global-ingress-capi-wali-aws-dev-1
        managing it'
      reason: Conflict
      status: "False"
      type: ingress-nginx.ingress-nginx/SveltosHelmReleaseReady
apiVersion: hmc.mirantis.com/v1alpha1
kind: ManagedCluster
metadata:
  . . .
  generation: 1
  name: wali-aws-dev-2
  namespace: hmc-system
  resourceVersion: "30889"
  uid: 9345a7c6-424b-4dd8-8472-32c225b909bd
spec:
  . . .
  services:
  - name: ingress-nginx
    namespace: ingress-nginx
    template: ingress-nginx-4-11-0
  servicesPriority: 500
  stopOnConflict: false
  template: aws-standalone-cp-0-0-2
status:
  conditions:
  - lastTransitionTime: "2024-10-25T07:57:52Z"
    message: Template is valid
    reason: Succeeded
    status: "True"
    type: TemplateReady
  - lastTransitionTime: "2024-10-25T07:57:52Z"
    message: Helm chart is valid
    reason: Succeeded
    status: "True"
    type: HelmChartReady
  - lastTransitionTime: "2024-10-25T07:57:53Z"
    message: Helm install succeeded for release hmc-system/wali-aws-dev-2.v1 with
      chart [email protected]
    reason: InstallSucceeded
    status: "True"
    type: HelmReleaseReady
  - lastTransitionTime: "2024-10-25T08:03:22Z"
    message: ManagedCluster is ready
    reason: Succeeded
    status: "True"
    type: Ready
  - lastTransitionTime: "2024-10-25T07:57:52Z"
    message: Credential is Ready
    reason: Succeeded
    status: "True"
    type: CredentialReady
  - lastTransitionTime: "2024-10-25T08:03:22Z"
    message: ""
    reason: Succeeded
    status: "True"
    type: ControlPlaneInitialized
  - lastTransitionTime: "2024-10-25T08:03:22Z"
    message: ""
    reason: Succeeded
    status: "True"
    type: ControlPlaneReady
  - lastTransitionTime: "2024-10-25T08:01:49Z"
    message: ""
    reason: Succeeded
    status: "True"
    type: InfrastructureReady
  - lastTransitionTime: "2024-10-25T08:03:24Z"
    message: ""
    reason: Succeeded
    status: "True"
    type: SveltosProfileReady
  observedGeneration: 1
  services:
  - clusterName: wali-aws-dev-2
    clusterNamespace: hmc-system
    conditions:
    - lastTransitionTime: "2024-10-25T08:18:22Z"
      message: ""
      reason: Provisioned
      status: "True"
      type: Helm
    - lastTransitionTime: "2024-10-25T08:18:22Z"
      message: Release ingress-nginx/ingress-nginx
      reason: Managing
      status: "True"
      type: ingress-nginx.ingress-nginx/SveltosHelmReleaseReady
apiVersion: hmc.mirantis.com/v1alpha1
kind: MultiClusterService
metadata:
  . . .
  generation: 1
  name: global-ingress
  resourceVersion: "38146"
  uid: bf677564-db9c-44b4-8cfc-30159881b96e
spec:
  clusterSelector:
    matchLabels:
      app.kubernetes.io/managed-by: Helm
  services:
  - name: ingress-nginx
    namespace: ingress-nginx
    template: ingress-nginx-4-11-3
  servicesPriority: 300
  stopOnConflict: false
status:
  conditions:
  - lastTransitionTime: "2024-10-25T08:36:24Z"
    message: ""
    reason: Succeeded
    status: "True"
    type: SveltosClusterProfileReady
  - lastTransitionTime: "2024-10-25T08:36:24Z"
    message: MultiClusterService is ready
    reason: Succeeded
    status: "True"
    type: Ready
  observedGeneration: 1
  services:
  - clusterName: wali-aws-dev-2
    clusterNamespace: hmc-system
    conditions:
    - lastTransitionTime: "2024-10-25T08:36:35Z"
      message: |
        cannot manage chart ingress-nginx/ingress-nginx. ClusterSummary p--wali-aws-dev-2-capi-wali-aws-dev-2 managing it.
      reason: Failed
      status: "False"
      type: Helm
    - lastTransitionTime: "2024-10-25T08:36:25Z"
      message: 'Release ingress-nginx/ingress-nginx: ClusterSummary p--wali-aws-dev-2-capi-wali-aws-dev-2
        managing it'
      reason: Conflict
      status: "False"
      type: ingress-nginx.ingress-nginx/SveltosHelmReleaseReady
  - clusterName: wali-aws-dev-1
    clusterNamespace: hmc-system
    conditions:
    - lastTransitionTime: "2024-10-25T08:36:24Z"
      message: ""
      reason: Provisioned
      status: "True"
      type: Helm
    - lastTransitionTime: "2024-10-25T08:36:25Z"
      message: Release ingress-nginx/ingress-nginx
      reason: Managing
      status: "True"
      type: ingress-nginx.ingress-nginx/SveltosHelmReleaseReady

@wahabmk wahabmk self-assigned this Oct 24, 2024
@wahabmk wahabmk force-pushed the services-status branch 7 times, most recently from 01227cd to dd44dfa Compare October 25, 2024 08:58
@wahabmk wahabmk marked this pull request as ready for review October 25, 2024 09:12
@wahabmk wahabmk force-pushed the services-status branch 2 times, most recently from 566a97a to 967c55e Compare October 25, 2024 10:33
go.mod Outdated Show resolved Hide resolved
api/v1alpha1/managedcluster_types.go Show resolved Hide resolved
internal/controller/managedcluster_controller.go Outdated Show resolved Hide resolved
internal/controller/multiclusterservice_controller.go Outdated Show resolved Hide resolved
internal/controller/multiclusterservice_controller.go Outdated Show resolved Hide resolved
internal/sveltos/profile.go Outdated Show resolved Hide resolved
internal/controller/multiclusterservice_controller.go Outdated Show resolved Hide resolved
@wahabmk wahabmk force-pushed the services-status branch 6 times, most recently from 01d0736 to 129bd22 Compare October 29, 2024 22:04
@wahabmk wahabmk force-pushed the services-status branch 5 times, most recently from 14efa75 to 44be7fa Compare October 31, 2024 07:36
@wahabmk wahabmk requested a review from zerospiel October 31, 2024 07:37
zerospiel
zerospiel previously approved these changes Oct 31, 2024
@wahabmk wahabmk force-pushed the services-status branch 2 times, most recently from 55fcc8e to bc6ae09 Compare October 31, 2024 14:45
@wahabmk wahabmk requested a review from zerospiel October 31, 2024 15:05
zerospiel
zerospiel previously approved these changes Oct 31, 2024
@wahabmk wahabmk force-pushed the services-status branch 2 times, most recently from 749fcae to ecf91a9 Compare November 6, 2024 08:42
@wahabmk wahabmk merged commit 7f755ce into Mirantis:main Nov 7, 2024
5 checks passed
@wahabmk wahabmk deleted the services-status branch November 7, 2024 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Implement Status for MultiClusterService Update Status on ManagedCluster based on Services Reconciliation
3 participants