30/05/2019
“Kubernetes is an open-source system for managing containerized applications across multiple hosts in a cluster. Kubernetes provides mechanisms for application deployment, scheduling, updating, maintenance, and scaling.”
$ kubectl
kubectl controls the Kubernetes cluster manager.
Find more information at https://github.com/kubernetes/kubernetes.
Usage:
kubectl [flags]
kubectl [command]
Available Commands:
get Display one or many resources
describe Show details of a specific resource or group of resources
create Create a resource by filename or stdin
...
FROM alpine:3.3
# install common packages
RUN apk add --update-cache curl bash openssl sudo && rm -rf /var/cache/apk/*
# install etcdctl and confd
RUN apk add --update-cache curl tar \
&& curl -sSL https://github.com/coreos/etcd/releases/download/v2.2.1/etcd-v2.2.1-linux-amd64.tar.gz \
| tar -vxz -C /usr/local/bin --strip=1 etcd-v2.2.1-linux-amd64/etcdctl \
&& chown root:root /usr/local/bin/etcdctl \
&& curl -sSL -o /usr/local/bin/confd https://github.com/kelseyhightower/confd/releases/download/v0.10.0/confd-0.10.0-linux-amd64 \
&& chmod +x /usr/local/bin/confd
# define execution environment
CMD ["/app/bin/boot"]
EXPOSE 8000
Runs containers and proxies service requests.
Supporting processes:
Represents a logical application.
Define states of pods
Service discovery for pods.
controllers/nginx-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
export NUM_MINIONS=2
export KUBERNETES_PROVIDER=vagrant
curl -sS https://get.k8s.io | bash
cd kubernetes/
ls
cd cluster/
ln -s kubectl.sh kubectl
export PATH=`pwd`:$PATH
kubectl get nodes
kubectl get pods
kubectl get services
cat manifests/k8s-basics-rc.yaml
kubectl create -f manifests/k8s-basics-rc.yaml
kubectl describe rc k8s-basics
kubectl get pods
kubectl describe pod
kubectl logs -f
kubectl exec -- ls -alh
kubectl scale rc k8s-basics --replicas=4
kubectl get pods --output=wide
curl http://10.245.1.3:8888
cat manifests/k8s-basics-svc.yaml
kubectl create -f manifests/k8s-basics-svc.yaml
kubectl get service
kubectl get service k8s-basics -o yaml
curl -sS http://10.245.1.3:/tree
# open in browser
# cleanup
kubectl delete svc k8s-basics
kubectl delete rc k8s-basics