Hello World
Following examples from https://github.com/DevOps-with-Kubernetes/examplesStarting minikube:
minikube start --vm-driver=noneExample helloworld_pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: example
spec:
containers:
- name: web
image: nginx
imagePullPolicy: Never
- name: centos
image: centos
imagePullPolicy: Never
command: ["bin/sh", "-c", "while : ; do curl http://localhost:80/ sleep 10; done"]
Run this using
service_pod_1.yamlkubectl create -f helloworld_pod.yaml
kubectl get pods
kubectl logs example -c centos
Cluster Service
apiVersion: v1service_pod_2.yaml
kind: ReplicationController
metadata:
name: nginx-1.12
spec:
replicas: 2
selector:
project: service_clusterip
service: web
version: "0.1"
template:
metadata:
name: nginx
labels:
project: service_clusterip
service: web
version: "0.1"
spec:
containers:
- name: nginx
image: nginx:1.12.0
ports:
- containerPort : 80
apiVersion: v1service.yaml
kind: ReplicationController
metadata:
name: nginx-1.13
spec:
replicas: 2
selector:
project: service_clusterip
service: web
version: "0.2"
template:
metadata:
name: nginx
labels:
project: service_clusterip
service: web
version: "0.2"
spec:
containers:
- name: nginx
image: nginx:1.13.1
ports:
- containerPort : 80
apiVersion: v1Run Service
kind: Service
metadata:
name: nginx-service
spec:
selector:
project: service_clusterip
service: web
ports:
- protocol: TCP
port : 80
targetPort: 80
name: http
kubectl create -f service_pod_1.yaml
kubectl create -f service_pod_2.yaml
kubectl create -f service.yaml
kubectl get service
kubectl get pods
kubectl describe pods nginx-1.13-2r9rf
kubectl get endpoints
checker.yaml
apiVersion: v1Find the logs
kind: Pod
metadata:
name: clusterip-chk
spec:
containers:
- name: centos
image: centos
command: ["/bin/sh", "-c", "while : ;do curl http://${NGINX_SERVICE_SERVICE_HOST}:80/; sleep 10; done"]
kubectl logs -f clusterip-chk
No comments:
Post a Comment