Tutorial : Getting Started with Kubernetes with Docker on Mac

  • Installing Docker on Mac Edge version
  • Go through the basic Kubernetes commands to validate our environment.
  • Docker is running
  • Kubernetes is running
  • A standalone Kubernetes server and client, as well as Docker CLI integration.
  • The Kubernetes server is a single-node cluster and is not configurable.
$ kubectl versionClient Version: version.Info{Major:”1", Minor:”8", GitVersion:”v1.8.4", GitCommit:”9befc2b8928a9426501d3bf62f72849d5cbcd5a3", GitTreeState:”clean”, BuildDate:”2017–11–20T05:28:34Z”, GoVersion:”go1.8.3", Compiler:”gc”, Platform:”darwin/amd64"}Server Version: version.Info{Major:”1", Minor:”8", GitVersion:”v1.8.2", GitCommit:”bdaeafa71f6c7c04636251031f93464384d54963", GitTreeState:”clean”, BuildDate:”2017–10–24T19:38:10Z”, GoVersion:”go1.8.3", Compiler:”gc”, Platform:”linux/amd64"}
$ kubectl config current-context
docker-for-desktop
$ kubectl config use-context docker-for-desktop
Switched to context "docker-for-desktop"
$ kubectl cluster-infoKubernetes master is running at https://localhost:6443
KubeDNS is running at https://localhost:6443/api/v1/namespaces/kube-system/services/kube-dns/proxy
$ kubectl get nodesNAME STATUS ROLES AGE VERSION
docker-for-desktop Ready master 7h v1.8.2
$ kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yamlsecret “kubernetes-dashboard-certs” created
serviceaccount “kubernetes-dashboard” created
role “kubernetes-dashboard-minimal” created
rolebinding “kubernetes-dashboard-minimal” created
deployment “kubernetes-dashboard” created
service “kubernetes-dashboard” created
$ kubectl get pods --namespace kube-systemNAME READY STATUS RESTARTS AGE
etcd-docker-for-desktop 1/1 Running 0 8h
kube-apiserver-docker-for-desktop 1/1 Running 0 7h
kube-controller-manager-docker-for-desktop 1/1 Running 0 8h
kube-dns-545bc4bfd4-l9tw9 3/3 Running 0 8h
kube-proxy-w8pq7 1/1 Running 0 8h
kube-scheduler-docker-for-desktop 1/1 Running 0 7h
kubernetes-dashboard-7798c48646-ctrtl 1/1 Running 0 3m
$ kubectl port-forward kubernetes-dashboard-7798c48646-ctrtl 8443:8443 --namespace kube-systemForwarding from 127.0.0.1:8443 -> 8443
$ kubectl run hello-nginx --image=nginx --port=80deployment “hello-nginx” created
$ kubectl get podsNAME READY STATUS RESTARTS AGE
hello-nginx-5d47cdc4b7-wxf9b 0/1 ContainerCreating 0 16s
$ kubectl get podsNAME READY STATUS RESTARTS AGE
hello-nginx-5d47cdc4b7-wxf9b 1/1 Running 0 3m
$ kubectl get podsNAME READY STATUS RESTARTS AGE
hello-nginx-5d47cdc4b7-wxf9b 1/1 Running 0 10m
$ kubectl describe pod hello-nginx-5d47cdc4b7-wxf9bName: hello-nginx-5d47cdc4b7-wxf9b
Namespace: default
Node: docker-for-desktop/192.168.65.3
Start Time: Wed, 10 Jan 2018 18:10:35 +0530
Labels: pod-template-hash=1803787063
run=hello-nginx
Annotations: kubernetes.io/created-by={“kind”:”SerializedReference”,”apiVersion”:”v1",”reference”:{“kind”:”ReplicaSet”,”namespace”:”default”,”name”:”hello-nginx-5d47cdc4b7",”uid”:”7415cff7-f603–11e7–9f7b-025000000…Status: Running
IP: 10.1.0.7
Created By: ReplicaSet/hello-nginx-5d47cdc4b7
Controlled By: ReplicaSet/hello-nginx-5d47cdc4b7
Containers:
hello-nginx:
Container ID: docker://a0c3309b61be4473bf6924ea2be9795de660f49bda36492785f94627690cbdae
Image: nginx
Image ID: docker-pullable://nginx@sha256:285b49d42c703fdf257d1e2422765c4ba9d3e37768d6ea83d7fe2043dad6e63d
Port: 80/TCP
State: Running
...// REST OF THE OUTPUT
$ kubectl get deploymentsNAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
hello-nginx 1 1 1 1 19m
$ kubectl expose deployment hello-nginx --type=NodePort
service “hello-nginx” exposed
$ kubectl get servicesNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-nginx NodePort 10.107.132.220 <none> 80:30259/TCP 1m
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 8h
$ kubectl describe service hello-nginxName: hello-nginx
Namespace: default
Labels: run=hello-nginx
Annotations: <none>
Selector: run=hello-nginx
Type: NodePort
IP: 10.107.132.220
Port: <unset> 80/TCP
TargetPort: 80/TCP
NodePort: <unset> 30259/TCP
Endpoints: 10.1.0.7:80
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
$ kubectl scale --replicas=3 deployment/hello-nginx
deployment "hello-nginx" scaled
$ kubectl get deploymentNAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
hello-nginx 3 3 3 3 45m

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
GFW VPN

GFW VPN

3 Followers

https://gfw.netlify.app 为中国用户提供vpn服务.join our network, rule your own internet