Run Symphony on Kubernetes
This tutorial shows you how to deploy Symphony to a Kubernetes cluster and use kubectl to interact with Symphony API in addition to REST API.
Part 1: Deploy Symphony to a Kubernetes cluster
-
Install Maestro and deploy Symphony to a Kubernetes cluster, to which your
kubectlis currently pointing:wget -q https://raw.githubusercontent.com/eclipse-symphony/symphony/master/cli/install/install.sh -O - | /bin/bash maestro uppowershell -Command "iwr -useb https://raw.githubusercontent.com/eclipse-symphony/symphony/master/cli/install/install.ps1 | iex" maestro upYou should see outputs like:
Checking kubectl ...found Checking kubectl context ...OK Checking Kubernetes connection ...OK Installing cert manager ...done Checking Helm ...found Checking Symphony API (Symphony) ...done Checking namespace existence ...done Deploying Symphony API (Symphony), chart: oci://ghcr.io/eclipse-symphony/helm/symphony, installServiceExt: true, with MQTT broker: false Deploying Symphony API (Symphony) ...done Checking public Symphony API address ... Symphony API: http://<Symphony REST API IP>:8080/v1alpha2/greetings Done! -
Check Symphony’s pod using
kubectl:kubectl get podsYou shoulde see a list of pods running:
NAME READY STATUS symphony-api-... 1/1 Running symphony-cert-manager-... 1/1 Running symphony-cert-manager-cainjector-... 1/1 Running symphony-cert-manager-webhook-... 1/1 Running symphony-controller-manager-... 2/2 Running symphony-redis-... 1/1 Running symphony-zipkin-... 1/1 Running
Part 2: Deploying a simple service
-
Use maestro to deploy the hello-k8s sample, which deploys a Prometheus service on Kubernetes:
maestro samples run hello-k8sYou should see outputs like this:
Creating target sample-k8s-target ... done Creating solution sample-prometheus-server ... done Creating solutionversion sample-prometheus-server-v-v1 ... done Creating instance sample-prometheus-instance ... done ... checking post-command condition ... checking post-command condition ⣯ NOTE: Navigate to http://<Prometheus service public IP>:9090/ to access the Promethus portal (it may take a few minutes for the LoadBalancer to be provisioned) -
Navigae to the above URL to visit Prometheus portal.
-
The sample creates a
sample-k8s-scopenamespace and deploys several resources. Usekubectlto examine them:kubectl get all -n sample-k8s-scopeYou should see something like:
AME READY STATUS RESTARTS AGE pod/sample-prometheus-instance-... 1/1 Running 0 38s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/sample-prometheus-instance LoadBalancer 10.0.214.131 <Public IP> 9090:32171/TCP 33s NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/sample-prometheus-instance 1/1 1 1 38s NAME DESIRED CURRENT READY AGE replicaset.apps/sample-prometheus-... 1 1 1 38sYou should see something like:
... IMAGE ... CREATED STATUS PORTS NAMES ... prom/prometheus ... 18 seconds ago Up 17 seconds 0.0.0.0:9090->9090/tcp sample-prometheus-server
Part 3: Examine Symphony objects
The sample deploys several Symphony objects:
- A
sample-k8s-targetTarget object that represents a deployment target - A
sample-prometheus-serverSolution object with asample-prometheus-server-v-v1version that represent the software being managed - A
sample-prometheus-instanceInstance object that describes a deployment of the software to the target
NOTE: See Orchestration Model for more details.
-
You can examine these objects using
kubectl:kubectl get target kubectl get solution kubectl get solutionversion kubectl get instance -
Alternatively, you can use
maestroto query the same objects.maestrogoes through the REST API, but you should see identical objects via either channel:maestro get target maestro get solution maestro get solutionversion maestro get instancemaestroalso support direct JSONPath queries, for example:maestro get instance --json-path "@.spec.target"This displays the Target name associated with the Instance:
NAME sample-k8s-target
Part 3: Clean up
-
Remove the Promethus service by removing the Instance object:
kubectl delete instance sample-prometheus-instance -
Once the Instance object is removed, Symphony state reconcilation removes what it represents. You can check with
kubecctl:kubectl get all -n sample-k8s-scopeThis should return an empty resource list:
No resources found in sample-k8s-scope namespace.NOTE: Symphony Kubernetes provider doesn’t remove namespaces
-
(Optional) Remove other Symphony objects:
kubectl delete solutionversion sample-prometheus-server-v-v1 kubectl delete solution sample-prometheus-server kubectl delete target sample-k8s-targetOr, remove the namespece altogether:
kubectl delete ns sample-k8s-scope