Chapter 10. Deploying workload with ManifestWork
You can deploy workloads onto your managed clusters from your multicluster engine for Kubernetes cluster. For example. See the following sample with ManifestWork to create a basic deployment on your managed cluster from your multicluster engine for Kubernetes cluster:
Log in to your multicluster engine for Kubernetes cluster:
oc loginCreate a YAML file to configure the
ManifestWorkresource as it is in the following example. ReplaceCLUSTER_NAMEwith the name of the managed cluster that you imported from the Importing a cluster documentation. The example YAML deploys to your managed clusterdefaultnamespace when you apply the file:apiVersion: work.open-cluster-management.io/v1 kind: ManifestWork metadata: name: hello-work namespace: ${CLUSTER_NAME} labels: app: hello spec: workload: manifests: - apiVersion: apps/v1 kind: Deployment metadata: name: hello namespace: default spec: selector: matchLabels: app: hello template: metadata: labels: app: hello spec: containers: - name: hello image: quay.io/asmacdo/busybox command: ['/bin/sh', '-c', 'echo "Hello, Kubernetes!" && sleep 300'] - apiVersion: v1 kind: Service metadata: labels: app: hello name: hello namespace: default spec: ports: - port: 8000 protocol: TCP targetPort: 8000 selector: app: helloApply the YAML file. Run the following command:
oc apply -f manifestwork.yamlRun the following command to check the status of the
ManifestWorkfrom your multicluster engine for Kubernetes cluster:oc get manifestwork -n ${CLUSTER_NAME} hello-work -o yamlLog in to your managed cluster to view the results. See the following command:
oc loginView the deployment that you created with your multicluster engine for Kubernetes cluster:
$ oc get deploy -n default NAME READY UP-TO-DATE AVAILABLE AGE hello 1/1 1 1 37sYou can also view the created pod with the following command:
$ oc get pod NAME READY STATUS RESTARTS AGE hello-65f58985ff-4rm57 1/1 Running 0 42sIf you view the logs for the created pod, you see a message similar to the following:
$ oc logs hello-65f58985ff-4rm57 Hello, Kubernetes!