Create multicloud workloads via YAML¶
In addition to creating workloads through images, they can also be created by entering YAML statements.
The steps for this creation method are relatively simple, as described below.
-
In the left navigation bar, click
multicloud Workloads
, and click theYAML Create
button in the upper right corner. -
For example, after entering the YAML statement for creating a Deployment, click
Next
. -
After entering the YAML statement of the deployment strategy, click
Next
. -
After entering the YAML statement of the differentiation strategy, click
OK
. -
Automatically return to the list of multicloud workloads, click
⋮
on the right side of the list, you can edit and modify the YAML, and you can also pause, restart, and delete the workload.
YAML example¶
The YAML editor that comes with the Multicloud Management module will automatically detect the YAML syntax, and if there is an error, a relevant prompt will appear. Here are some common examples that you can use with a little modification.
Deployment example¶
#Kubernetes Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: demo-nginx
labels:
app: demo-nginx
spec:
replicas: 1
selector:
matchLabels:
app: demo-nginx
template:
metadata:
labels:
app: demo-nginx
spec:
containers:
- image: nginx
name: nginx
Deployment strategy example¶
#Karmada PropagationPolicy
apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
name: demo-nginx-pp
namespace: default # (1)
spec:
resourceSelectors:
- apiVersion: apps/v1
kind: Deployment
name: demo-nginx # (2)
placement:
clusterAffinity:
clusterNames:
- demo-stage
- demo-dev
- The default namespace is
default
. - If no namespace is specified, the namespace is inherited from the parent object scope.
Differentiation strategy example¶
#KarmadaOverridePolicy
apiVersion: policy.karmada.io/v1alpha1
kind: OverridePolicy
metadata:
name: demo-nginx-op
spec:
resourceSelectors:
- apiVersion: apps/v1
kind: Deployment
name: demo-nginx
overrideRules:
- targetCluster:
clusterNames:
- demo-dev
overriders:
plaintext:
- path: "/metadata/labels/env"
operator: add
value: demo-dev
- targetCluster:
clusterNames:
- demo-stage
overriders:
plaintext:
- path: "/metadata/labels/env"
operator: add
value: demo-stage