Skip to content

Commit

Permalink
Merge pull request Mirantis#265 from Mirantis/mnaged
Browse files Browse the repository at this point in the history
Rename Deployment into ManagedCluster
  • Loading branch information
Kshatrix authored Sep 5, 2024
2 parents 3c842b4 + d37fc78 commit 1ae16bb
Show file tree
Hide file tree
Showing 30 changed files with 348 additions and 347 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,11 @@ dev-creds-apply: dev-$(DEV_PROVIDER)-creds

.PHONY: dev-provider-apply
dev-provider-apply: envsubst
@NAMESPACE=$(NAMESPACE) $(ENVSUBST) -no-unset -i config/dev/$(DEV_PROVIDER)-deployment.yaml | $(KUBECTL) apply -f -
@NAMESPACE=$(NAMESPACE) $(ENVSUBST) -no-unset -i config/dev/$(DEV_PROVIDER)-managedcluster.yaml | $(KUBECTL) apply -f -

.PHONY: dev-provider-delete
dev-provider-delete: envsubst
@NAMESPACE=$(NAMESPACE) $(ENVSUBST) -no-unset -i config/dev/$(DEV_PROVIDER)-deployment.yaml | $(KUBECTL) delete -f -
@NAMESPACE=$(NAMESPACE) $(ENVSUBST) -no-unset -i config/dev/$(DEV_PROVIDER)-managedcluster.yaml | $(KUBECTL) delete -f -

.PHONY: cli-install
cli-install: clusterawsadm clusterctl
Expand Down
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ For details about the `Template system` in HMC, see [Templates system](docs/temp

If you want to deploy hostded control plate template, make sure to check additional notes on [Hosted control plane](docs/aws/hosted-control-plane.md).

2. Create the file with the `Deployment` configuration:
2. Create the file with the `ManagedCluster` configuration:

> Substitute the parameters enclosed in angle brackets with the corresponding values.\
> Enable the `dryRun` flag if required. For details, see [Dry run](#dry-run).

```yaml
apiVersion: hmc.mirantis.com/v1alpha1
kind: Deployment
kind: ManagedCluster
metadata:
name: <cluster-name>
namespace: <cluster-namespace>
Expand All @@ -128,42 +128,42 @@ spec:
<cluster-configuration>
```

3. Create the `Deployment` object:
3. Create the `ManagedCluster` object:

`kubectl create -f deployment.yaml`
`kubectl create -f managedcluster.yaml`

4. Check the status of the newly created `Deployment` object:
4. Check the status of the newly created `ManagedCluster` object:

`kubectl -n <deployment-namespace> get deployment.hmc <deployment-name> -o=yaml`
`kubectl -n <managedcluster-namespace> get managedcluster <managedcluster-name> -o=yaml`

5. Wait for infrastructure to be provisioned and the cluster to be deployed (the provisioning starts only when
`spec.dryRun` is disabled):

`kubectl -n <deployment-namespace> get cluster <deployment-name> -o=yaml`
`kubectl -n <managedcluster-namespace> get cluster <managedcluster-name> -o=yaml`

> You may also watch the process with the `clusterctl describe` command (requires the `clusterctl` CLI to be installed):
> ```
> clusterctl describe cluster <deployment-name> -n <deployment-namespace> --show-conditions all
> clusterctl describe cluster <managedcluster-name> -n <managedcluster-namespace> --show-conditions all
> ```

6. Retrieve the `kubeconfig` of your managed cluster:

```
kubectl get secret -n hmc-system <deployment-name>-kubeconfig -o=jsonpath={.data.value} | base64 -d > kubeconfig
kubectl get secret -n hmc-system <managedcluster-name>-kubeconfig -o=jsonpath={.data.value} | base64 -d > kubeconfig
```

### Dry run

HMC `Deployment` supports two modes: with and without (default) `dryRun`.
HMC `ManagedCluster` supports two modes: with and without (default) `dryRun`.

If no configuration (`spec.config`) provided, the `Deployment` object will be populated with defaults
If no configuration (`spec.config`) provided, the `ManagedCluster` object will be populated with defaults
(default configuration can be found in the corresponding `Template` status) and automatically marked as `dryRun`.

Here is an example of the `Deployment` object with default configuration:
Here is an example of the `ManagedCluster` object with default configuration:

```yaml
apiVersion: hmc.mirantis.com/v1alpha1
kind: Deployment
kind: ManagedCluster
metadata:
name: <cluster-name>
namespace: <cluster-namespace>
Expand Down Expand Up @@ -198,11 +198,11 @@ spec:
After you adjust your configuration and ensure that it passes validation (`TemplateReady` condition
from `status.conditions`), remove the `spec.dryRun` flag to proceed with the deployment.

Here is an example of a `Deployment` object that passed the validation:
Here is an example of a `ManagedCluster` object that passed the validation:

```yaml
apiVersion: hmc.mirantis.com/v1alpha1
kind: Deployment
kind: ManagedCluster
metadata:
name: aws-standalone
namespace: aws
Expand Down Expand Up @@ -232,7 +232,7 @@ spec:
status: "True"
type: HelmChartReady
- lastTransitionTime: "2024-07-22T09:25:49Z"
message: Deployment is ready
message: ManagedCluster is ready
reason: Succeeded
status: "True"
type: Ready
Expand All @@ -245,7 +245,7 @@ spec:

`kubectl delete management.hmc hmc -n hmc-system`

> Note: make sure you have no HMC Deployment objects left in the cluster prior to Management deletion
> Note: make sure you have no HMC ManagedCluster objects left in the cluster prior to Management deletion

2. Remove the `hmc` Helm release:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,24 @@ import (
)

const (
DeploymentFinalizer = "hmc.mirantis.com/deployment"
ManagedClusterFinalizer = "hmc.mirantis.com/managed-cluster"

FluxHelmChartNameKey = "helm.toolkit.fluxcd.io/name"
HMCManagedLabelKey = "hmc.mirantis.com/managed"
HMCManagedLabelValue = "true"
)

const (
// ManagedClusterKind is the string representation of a ManagedCluster.
ManagedClusterKind = "ManagedCluster"

// TemplateReadyCondition indicates the referenced Template exists and valid.
TemplateReadyCondition = "TemplateReady"
// HelmChartReadyCondition indicates the corresponding HelmChart is valid and ready.
HelmChartReadyCondition = "HelmChartReady"
// HelmReleaseReadyCondition indicates the corresponding HelmRelease is ready and fully reconciled.
HelmReleaseReadyCondition = "HelmReleaseReady"
// ReadyCondition indicates the Deployment is ready and fully reconciled.
// ReadyCondition indicates the ManagedCluster is ready and fully reconciled.
ReadyCondition string = "Ready"
)

Expand All @@ -54,8 +57,8 @@ const (
ProgressingReason string = "Progressing"
)

// DeploymentSpec defines the desired state of Deployment
type DeploymentSpec struct {
// ManagedClusterSpec defines the desired state of ManagedCluster
type ManagedClusterSpec struct {
// DryRun specifies whether the template should be applied after validation or only validated.
// +optional
DryRun bool `json:"dryRun,omitempty"`
Expand All @@ -70,12 +73,12 @@ type DeploymentSpec struct {
Config *apiextensionsv1.JSON `json:"config,omitempty"`
}

// DeploymentStatus defines the observed state of Deployment
type DeploymentStatus struct {
// ManagedClusterStatus defines the observed state of ManagedCluster
type ManagedClusterStatus struct {
// ObservedGeneration is the last observed generation.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
// Conditions contains details for the current state of the Deployment
// Conditions contains details for the current state of the ManagedCluster
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

Expand All @@ -86,27 +89,27 @@ type DeploymentStatus struct {
// +kubebuilder:printcolumn:name="status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",description="Status",priority=0
// +kubebuilder:printcolumn:name="dryRun",type="string",JSONPath=".spec.dryRun",description="Dry Run",priority=1

// Deployment is the Schema for the deployments API
type Deployment struct {
// ManagedCluster is the Schema for the managedclusters API
type ManagedCluster struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec DeploymentSpec `json:"spec,omitempty"`
Status DeploymentStatus `json:"status,omitempty"`
Spec ManagedClusterSpec `json:"spec,omitempty"`
Status ManagedClusterStatus `json:"status,omitempty"`
}

func (in *Deployment) HelmValues() (values map[string]interface{}, err error) {
func (in *ManagedCluster) HelmValues() (values map[string]interface{}, err error) {
if in.Spec.Config != nil {
err = yaml.Unmarshal(in.Spec.Config.Raw, &values)
}
return values, err
}

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

func (in *Deployment) InitConditions() {
func (in *ManagedCluster) InitConditions() {
apimeta.SetStatusCondition(in.GetConditions(), metav1.Condition{
Type: TemplateReadyCondition,
Status: metav1.ConditionUnknown,
Expand All @@ -131,19 +134,19 @@ func (in *Deployment) InitConditions() {
Type: ReadyCondition,
Status: metav1.ConditionUnknown,
Reason: ProgressingReason,
Message: "Deployment is not yet ready",
Message: "ManagedCluster is not yet ready",
})
}

//+kubebuilder:object:root=true

// DeploymentList contains a list of Deployment
type DeploymentList struct {
// ManagedClusterList contains a list of ManagedCluster
type ManagedClusterList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Deployment `json:"items"`
Items []ManagedCluster `json:"items"`
}

func init() {
SchemeBuilder.Register(&Deployment{}, &DeploymentList{})
SchemeBuilder.Register(&ManagedCluster{}, &ManagedClusterList{})
}
6 changes: 2 additions & 4 deletions api/v1alpha1/template_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ const (
ManagementKind = "Management"
// TemplateKind is the string representation of a Template.
TemplateKind = "Template"
// DeploymentKind is the string representation of a Deployment.
DeploymentKind = "Deployment"

// ChartAnnotationType is an annotation containing the type of Template.
ChartAnnotationType = "hmc.mirantis.com/type"
Expand All @@ -47,7 +45,7 @@ const (
type TemplateType string

const (
// TemplateTypeDeployment is the type used for creating HMC Deployment objects
// TemplateTypeDeployment is the type used for creating HMC ManagedCluster objects
TemplateTypeDeployment TemplateType = "deployment"
// TemplateTypeProvider is the type used for adding CAPI providers in the HMC Management object.
TemplateTypeProvider TemplateType = "provider"
Expand Down Expand Up @@ -92,7 +90,7 @@ type TemplateStatus struct {
// +optional
Description string `json:"description,omitempty"`
// Config demonstrates available parameters for template customization,
// that can be used when creating Deployment objects.
// that can be used when creating ManagedCluster objects.
// +optional
Config *apiextensionsv1.JSON `json:"config,omitempty"`
// ChartRef is a reference to a source controller resource containing the
Expand Down
Loading

0 comments on commit 1ae16bb

Please sign in to comment.