Add app deploy scenario (#7)

Signed-off-by: Jian Qiu <jqiu@redhat.com>
This commit is contained in:
Jian Qiu
2021-12-14 04:22:38 +08:00
committed by GitHub
parent 18ca491d46
commit c4e2a5d8af
9 changed files with 115 additions and 1 deletions

View File

@@ -33,7 +33,8 @@ In addition, developers can leverage [Addon framework](https://github.com/open-c
* Centrally create, update, and delete Kubernetes clusters across multiple private and public clouds.
* Automatically deploy applications to specific clusters by subscribing to different workload (resource) channels, such as GitHub, Helm repository, ObjectStore, and resource templates.
The application model defines a Kubernetes-first way of describing the application. Your existing Kubernetes apps or `kustomized` apps can be adapted with the addition of a few new objects: [Channel](https://github.com/open-cluster-management-io/multicloud-operators-channel), and [Subscription](https://github.com/open-cluster-management-io/multicloud-operators-subscription). Changes made to the app are then easily delivered to managed clusters based on the dynamic placement engine.
The application model defines a Kubernetes-first way of describing the application. Your existing Kubernetes apps or `kustomized` apps can be adapted with the addition of a few new objects: [Channel](https://github.com/open-cluster-management-io/multicloud-operators-channel), and [Subscription](https://github.com/open-cluster-management-io/multicloud-operators-subscription). Changes made to the app are then easily delivered to managed clusters based on the dynamic placement engine. See [deploy a helm chart][solutions/deploy-a-helm-chart] on how
to install application manager addon in OCM and deploy helm charts in multiple clusters.
### GRC: Governance, Risk and Compliance across Kubernetes clusters

View File

@@ -0,0 +1,37 @@
# Deploy a Helm Chart
## Prerequisite
Set up the dev environment in your local machine following [setup dev environment](../setup-dev-environment).
## Install application addon on OCM
Install application manager addon on the hub cluster
```
kubectl config use kind-hub
clusteradm install addons --names application-manager
```
Install application manager agent on all the managed clusters
```
clusteradm enable addons --names application-manager --clusters cluster1,cluster2
```
You will see that all agents is available after waiting a while
```
$ kubectl get managedclusteraddon --all-namespaces
NAMESPACE NAME AVAILABLE DEGRADED PROGRESSING
cluster1 application-manager True
cluster2 application-manager True
```
## Deploy a helm chart to cluster1
Run `./deploy.sh` to deploy the helm chart on cluster1
It will create a [channel](manifests/channel.yaml) which specifies a helm repo, a [placement](manifests/placement.yaml)
to select one or multiple clusters, and a [subscription](manifests/subscription.yaml) to deploy the helm chart. Try
update `placement` to see how the chart deployment is changed.

View File

@@ -0,0 +1,22 @@
#!/bin/bash
cd $(dirname ${BASH_SOURCE})
set -e
hubctx="kind-hub"
kubectl config use ${hubctx}
echo "Add cluster1, cluster2 to the clusterset"
kubectl label managedcluster cluster1 cluster.open-cluster-management.io/clusterset=app-demo --overwrite
kubectl label managedcluster cluster2 cluster.open-cluster-management.io/clusterset=app-demo --overwrite
echo "Label cluster1 so placement will select cluster1 only"
kubectl label managedcluster cluster1 purpose=test --overwrite
echo "Deploy the application with placement"
kubectl apply -f manifests/

View File

@@ -0,0 +1,9 @@
apiVersion: apps.open-cluster-management.io/v1
kind: Channel
metadata:
name: demo-helmrepo
namespace: default
spec:
type: HelmRepo
pathname: https://charts.helm.sh/stable/
insecureSkipVerify: true

View File

@@ -0,0 +1,4 @@
apiVersion: cluster.open-cluster-management.io/v1alpha1
kind: ManagedClusterSet
metadata:
name: app-demo

View File

@@ -0,0 +1,7 @@
apiVersion: cluster.open-cluster-management.io/v1alpha1
kind: ManagedClusterSetBinding
metadata:
name: app-demo
namespace: default
spec:
clusterSet: app-demo

View File

@@ -0,0 +1,14 @@
apiVersion: cluster.open-cluster-management.io/v1alpha1
kind: Placement
metadata:
name: demo-placement
namespace: default
spec:
numberOfClusters: 1
clusterSets:
- app-demo
predicates:
- requiredClusterSelector:
labelSelector:
matchLabels:
purpose: test

View File

@@ -0,0 +1,20 @@
apiVersion: apps.open-cluster-management.io/v1
kind: Subscription
metadata:
name: demo-subscription
namespace: default
spec:
channel: default/demo-helmrepo
name: nginx-ingress
placement:
placementRef:
name: demo-placement
kind: Placement
packageOverrides:
- packageName: nginx-ingress
packageAlias: nginx-ingress-simple
packageOverrides:
- path: spec
value:
defaultBackend:
replicaCount: 2

0
solutions/setup-dev-environment/local-up.sh Normal file → Executable file
View File