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

WIP Adding sevriceTemplates to ManagedCluster #11

Merged
merged 25 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4586bf0
Automatically create TemplateManagement
eromanova Sep 23, 2024
e360dc5
Validate TemplateManagement is singleton
eromanova Sep 23, 2024
d3ab30a
Forbid to remove TemplateManagement
eromanova Sep 23, 2024
bcb3a7c
Merge pull request #380 from eromanova/tm-creation
Kshatrix Sep 25, 2024
f6f5165
Fix incorrect condition to enable CAPI
zerospiel Sep 25, 2024
c81b512
Merge pull request #390 from zerospiel/incorrect_capi_enable
eromanova Sep 25, 2024
6d2d138
Add Credential CR and controller
a13x5 Sep 18, 2024
a05358e
Add CODEOWNERS
DinaBelova Sep 25, 2024
7190acb
Merge pull request #394 from Mirantis/codeowners
squizzi Sep 25, 2024
49784fe
Bump github.com/fluxcd/source-controller/api from 1.3.0 to 1.4.1
dependabot[bot] Sep 26, 2024
dab4275
Implemented Azure e2e tests
kylewuolle Sep 18, 2024
b199e14
Merge pull request #352 from Mirantis/azure-e2e-tests
kylewuolle Sep 26, 2024
1477f9d
Merge pull request #403 from Mirantis/dependabot/go_modules/github.co…
Kshatrix Sep 27, 2024
040227a
Merge pull request #342 from a13x5/credentials-controller
Kshatrix Sep 27, 2024
5890fb8
Bump github.com/fluxcd/helm-controller/api from 1.0.1 to 1.1.0
dependabot[bot] Sep 27, 2024
011ff4d
Chores with human linter
zerospiel Sep 28, 2024
037a0e2
Merge pull request #408 from Mirantis/dependabot/go_modules/github.co…
Kshatrix Sep 28, 2024
973489e
Merge pull request #409 from zerospiel/human_linter
Kshatrix Sep 28, 2024
f801438
Removal of in repo docs - doc now in project-2a-docs repo (#404)
p5ntangle Sep 30, 2024
2dadc26
Fix CP providers label in charts meta
zerospiel Sep 30, 2024
b8230b3
Merge pull request #412 from zerospiel/fix_cp_label
Kshatrix Sep 30, 2024
24da5a0
Add Services to ManagedCluster to deploy on target cluster
wahabmk Sep 25, 2024
32d9ee5
Addressed review comments for adding services to ManagedCluster
wahabmk Sep 26, 2024
dadff0a
Set Profile.Spec.HelmCharts fields based on default or oci source reg…
wahabmk Sep 27, 2024
f440cc4
Delete Sveltos Profile before releasing Cluster
wahabmk Oct 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ env:
AWS_REGION: us-west-2
AWS_ACCESS_KEY_ID: ${{ secrets.CI_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_AWS_SECRET_ACCESS_KEY }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.CI_AZURE_SUBSCRIPTION_ID }}
AZURE_TENANT_ID: ${{ secrets.CI_AZURE_TENANT_ID }}
AZURE_CLIENT_ID: ${{ secrets.CI_AZURE_CLIENT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.CI_AZURE_CLIENT_SECRET }}
NAMESPACE: hmc-system

jobs:
e2etest:
Expand Down
3 changes: 3 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* @Kshatrix @eromanova @a13x5
/.github/ @Kshatrix @squizzi @eromanova @a13x5
/test/ @Kshatrix @squizzi @eromanova @a13x5
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ test: generate-all fmt vet envtest tidy external-crd ## Run tests.
# compatibility with other vendors.
.PHONY: test-e2e # Run the e2e tests using a Kind k8s instance as the management cluster.
test-e2e: cli-install
KIND_CLUSTER_NAME="hmc-test" KIND_VERSION=$(KIND_VERSION) go test ./test/e2e/ -v -ginkgo.v -timeout=2h
KIND_CLUSTER_NAME="hmc-test" KIND_VERSION=$(KIND_VERSION) go test ./test/e2e/ -v -ginkgo.v -timeout=3h

.PHONY: lint
lint: golangci-lint ## Run golangci-lint linter & yamllint
Expand Down Expand Up @@ -269,7 +269,11 @@ helm-push: helm-package
chart_version=$$(echo $$base | grep -o "v\{0,1\}[0-9]\+\.[0-9]\+\.[0-9].*"); \
chart_name="$${base%-"$$chart_version"}"; \
echo "Verifying if chart $$chart_name, version $$chart_version already exists in $(REGISTRY_REPO)"; \
chart_exists=$$($(HELM) pull $$repo_flag $(REGISTRY_REPO) $$chart_name --version $$chart_version --destination /tmp 2>&1 | grep "not found" || true); \
if $(REGISTRY_IS_OCI); then \
chart_exists=$$($(HELM) pull $$repo_flag $(REGISTRY_REPO)/$$chart_name --version $$chart_version --destination /tmp 2>&1 | grep "not found" || true); \
else \
chart_exists=$$($(HELM) pull $$repo_flag $(REGISTRY_REPO) $$chart_name --version $$chart_version --destination /tmp 2>&1 | grep "not found" || true); \
fi; \
if [ -z "$$chart_exists" ]; then \
echo "Chart $$chart_name version $$chart_version already exists in the repository."; \
else \
Expand Down Expand Up @@ -303,7 +307,7 @@ dev-release:

.PHONY: dev-aws-creds
dev-aws-creds: envsubst
@NAMESPACE=$(NAMESPACE) $(ENVSUBST) -no-unset -i config/dev/aws-credentials.yaml | $(KUBECTL) apply -f -
@NAMESPACE=$(NAMESPACE) $(ENVSUBST) -i config/dev/aws-credentials.yaml | $(KUBECTL) apply -f -

.PHONY: dev-azure-creds
dev-azure-creds: envsubst
Expand Down Expand Up @@ -374,7 +378,7 @@ ENVSUBST ?= $(LOCALBIN)/envsubst-$(ENVSUBST_VERSION)
AWSCLI ?= $(LOCALBIN)/aws

## Tool Versions
CONTROLLER_TOOLS_VERSION ?= v0.14.0
CONTROLLER_TOOLS_VERSION ?= v0.16.3
ENVTEST_VERSION ?= release-0.17
GOLANGCI_LINT_VERSION ?= v1.61.0
HELM_VERSION ?= v3.15.1
Expand Down
9 changes: 9 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,13 @@ resources:
kind: ServiceTemplateChain
path: github.com/Mirantis/hmc/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: hmc.mirantis.com
group: hmc.mirantis.com
kind: Credential
path: github.com/Mirantis/hmc/api/v1alpha1
version: v1alpha1
version: "3"
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# Mirantis Hybrid Cloud Platform
# Mirantis Hybrid Multi Cluster

## Overview

Mirantis Hybrid Multi Cluster is part of Mirantis Project 2A which is focused on delivering a
open source approach to providing an enterprise grade multi-cluster kubernetes managment solution
based entirely on standard open source tooling.

## Documentation

Detailed documentation is available in [Project 2A Docs](https://mirantis.github.io/project-2a-docs/)

## Installation

Expand Down Expand Up @@ -34,10 +44,7 @@ Optionally, the following CLIs may be helpful:

### Providers configuration

Follow the instruction to configure providers. Currently supported providers:
* [AWS](docs/aws/main.md#prepare-the-aws-infra-provider)
* [Azure](docs/azure/main.md)
* [vSphere](docs/vsphere/main.md)
Full details on the provider configuration can be found in the Project 2A Docs, see [Documentation](#documentation)

### Installation

Expand All @@ -47,8 +54,6 @@ export KUBECONFIG=<path-to-management-kubeconfig>
helm install hmc oci://ghcr.io/mirantis/hmc/charts/hmc --version <hmc-version> -n hmc-system --create-namespace
```

See [HMC configuration options](templates/hmc/values.yaml).

#### Extended Management configuration

By default, the Hybrid Container Cloud is being deployed with the following configuration:
Expand Down Expand Up @@ -106,9 +111,7 @@ export KUBECONFIG=<path-to-management-kubeconfig>
kubectl get template -n hmc-system -o go-template='{{ range .items }}{{ if eq .status.type "deployment" }}{{ .metadata.name }}{{ printf "\n" }}{{ end }}{{ end }}'
```

For details about the `Template system` in HMC, see [Templates system](docs/templates/main.md#templates-system).

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).
If you want to deploy hostded control plate template, make sure to check additional notes on Hosted control plane in 2A Docs, see [Documentation](#documentation).

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

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

package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type CredentialState string

const (
CredentialReady CredentialState = "Ready"
CredentialNotFound CredentialState = "Cluster Identity not found"
CredentialWrongType CredentialState = "Mismatched type"
)

// CredentialSpec defines the desired state of Credential
type CredentialSpec struct {
// Reference to the Credential Identity
IdentityRef *corev1.ObjectReference `json:"identityRef"`
// Description of the Credential object
Description string `json:"description,omitempty"` // WARN: noop
}

// CredentialStatus defines the observed state of Credential
type CredentialStatus struct {
State CredentialState `json:"state,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:shortName=cred
// +kubebuilder:printcolumn:name="State",type=string,JSONPath=`.status.state`
// +kubebuilder:printcolumn:name="Description",type=string,JSONPath=`.spec.description`

// Credential is the Schema for the credentials API
type Credential struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec CredentialSpec `json:"spec,omitempty"`
Status CredentialStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&Credential{}, &CredentialList{})
}
33 changes: 31 additions & 2 deletions api/v1alpha1/managedcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ const (
BlockingFinalizer = "hmc.mirantis.com/cleanup"
ManagedClusterFinalizer = "hmc.mirantis.com/managed-cluster"

FluxHelmChartNameKey = "helm.toolkit.fluxcd.io/name"
FluxHelmChartNameKey = "helm.toolkit.fluxcd.io/name"
FluxHelmChartNamespaceKey = "helm.toolkit.fluxcd.io/namespace"

HMCManagedLabelKey = "hmc.mirantis.com/managed"
HMCManagedLabelValue = "true"

Expand All @@ -36,6 +38,8 @@ const (
// ManagedClusterKind is the string representation of a ManagedCluster.
ManagedClusterKind = "ManagedCluster"

// CredentialReadyCondition indicates if referenced Credential exists and has Ready state
CredentialReadyCondition = "CredentialReady"
// TemplateReadyCondition indicates the referenced Template exists and valid.
TemplateReadyCondition = "TemplateReady"
// HelmChartReadyCondition indicates the corresponding HelmChart is valid and ready.
Expand All @@ -60,6 +64,26 @@ const (
ProgressingReason string = "Progressing"
)

// ManagedClusterServiceSpec represents a Service within ManagedCluster
type ManagedClusterServiceSpec struct {
// Template is a reference to a Template object located in the same namespace.
// +kubebuilder:validation:MinLength=1
Template string `json:"template"`
// Disable can be set to disable handling of this service.
// +optional
Disable bool `json:"disable"`
// Name is the chart release.
// +kubebuilder:validation:MinLength=1
Name string `json:"name"`
// Namespace is the namespace the release will be installed in.
// It will default to Name if not provided.
// +optional
Namespace string `json:"namespace"`
// Values is the helm values to be passed to the template.
// +optional
Values *apiextensionsv1.JSON `json:"values,omitempty"`
}

// ManagedClusterSpec defines the desired state of ManagedCluster
type ManagedClusterSpec struct {
// Config allows to provide parameters for template customization.
Expand All @@ -72,7 +96,12 @@ type ManagedClusterSpec struct {
// Template is a reference to a Template object located in the same namespace.
Template string `json:"template"`
// DryRun specifies whether the template should be applied after validation or only validated.
DryRun bool `json:"dryRun,omitempty"`
DryRun bool `json:"dryRun,omitempty"`
Credential string `json:"credential,omitempty"`
// Services is a list of services created via ServiceTemplates
// that could be installed on the target cluster.
// +optional
Services []ManagedClusterServiceSpec `json:"services,omitempty"`
}

// ManagedClusterStatus defines the observed state of ManagedCluster
Expand Down
6 changes: 4 additions & 2 deletions api/v1alpha1/management_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ const (

CoreCAPIName = "capi"

ManagementName = "hmc"
ManagementFinalizer = "hmc.mirantis.com/management"
ManagementKind = "Management"
ManagementName = "hmc"
ManagementFinalizer = "hmc.mirantis.com/management"
TemplateManagementName = "hmc"
)

// ManagementSpec defines the desired state of Management
Expand Down
2 changes: 2 additions & 0 deletions api/v1alpha1/templatemanagement_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const TemplateManagementKind = "TemplateManagement"

// TemplateManagementSpec defines the desired state of TemplateManagement
type TemplateManagementSpec struct {
// AccessRules is the list of access rules. Each AccessRule enforces
Expand Down
Loading