Hands-on Training:
presented by…
oc
or kubectl
cli tools?Similar goals:
Different Approaches:
OpenStack: Expose cluster resources (infrastructure) via API endpoints
Kubernetes: API endpoints are used to model operational requirements (declaratively). Cluster resources are obscured, presented in aggregate, and are managed indirectly via automation
IaaS (OpenStack) → distributed hardware
CaaS (Kubernetes) → distributed OS kernel
PaaS (OpenShift) → distributed OS distro
↓
Try using kubectl
to list resources by type:
kubectl get nodes
Request the same info, but output the results as structured yaml:
kubectl get nodes -o yaml
Fetch an individual resource by type/id
, output as json
:
kubectl get node/minikube -o json
View human-readable API output:
kubectl describe node/minikube
List resources by type:
kubectl get pods
Create a new resource based on a json object specification:
curl https://raw.githubusercontent.com/ryanj/metrics-k8s/master/pod.json
kubectl create -f https://raw.githubusercontent.com/ryanj/metrics-k8s/master/pod.json
List resources by type:
kubectl get pods
Fetch a resource by type and id, output the results as yaml
:
kubectl get pod metrics-k8s -o yaml
Notice any changes?
Expose the pod by creating a new service
(or "loadbalancer"):
kubectl expose pod/metrics-k8s --port 2015 --type=NodePort
Contact your newly-exposed pod using the associated service id:
minikube service metrics-k8s
Schedule a pod to be deleted:
kubectl delete pod metrics-k8s
Contact the related service. What happens?:
minikube service metrics-k8s
Delete the service:
kubectl delete service metrics-k8s
Create a specification for your deployment
:
kubectl run metrics-k8s --image=quay.io/ryanj/metrics-k8s \
--expose --port=2015 --service-overrides='{ "spec": { "type": "NodePort" } }' \
--dry-run -o yaml > deployment.yaml
View the generated deployment spec file:
cat deployment.yaml
Create a new resource based on your yaml specification:
kubectl create -f deployment.yaml
List resources by type:
kubectl get po,svc
Connect to your new deployment via the associated service id:
minikube service metrics-k8s
Scale up the metrics-k8s
deployment to 3 replicas:
kubectl scale deploy/metrics-k8s --replicas=3
List pods:
kubectl get po
Edit deploy/metrics-k8s
, setting spec.replicas
to 5
:
kubectl edit deploy/metrics-k8s -o json
Save and quit. What happens?
kubectl get pods
Watch for changes to pod
resources:
kubectl get pods --watch
In another terminal, delete several pods by id:
kubectl delete pod $(kubectl get pods | grep ^metrics-k8s | cut -f1 -s -d' ' | head -n 3 | tr '\n' ' ')
What happend? How many pods remain?
kubectl get pods
↓
Today's hands-on workshop is available at:
http://content-workshop.apps.openstack.openshiftworkshop.com
by Ramon Rodriguez of Red Hat
by Ramon Rodriguez of Red Hat
by Ramon Rodriguez of Red Hat
by Ramon Rodriguez of Red Hat