集群状态
[root@k8s-master1 ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-master1 Ready <none> 17h v1.10.4
k8s-master2 Ready <none> 17h v1.10.4
k8s-master3 Ready <none> 17h v1.10.4
k8s-node3 Ready <none> 17h v1.10.4
[root@k8s-master1 ~]# kubectl get cs
NAME STATUS MESSAGE ERROR
etcd-1 Healthy {"health":"true"}
etcd-2 Healthy {"health":"true"}
etcd-0 Healthy {"health":"true"}
scheduler Healthy ok
controller-manager Healthy ok
[root@k8s-master1 ~]#
7.1
创建测试文件
[root@k8s-master1 ~]# cat httpd-svc.yaml
apiVersion: v1
kind: Service
metadata:
name: httpd-svc
spec:
ports:
- port: 80
selector:
app: httpd-app
type: NodePort
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: httpd-app
spec:
replicas: 5
selector:
matchLabels:
app: httpd-app
template:
metadata:
labels:
app: httpd-app
spec:
containers:
- image: httpd
name: httpd-app
[root@k8s-master1 ~]#
[root@k8s-master1 ~]# kubectl get po
NAME READY STATUS RESTARTS AGE
httpd-app-6dc78c4869-8dmmq 1/1 Running 0 58s
httpd-app-6dc78c4869-dbpxc 1/1 Running 0 58s
httpd-app-6dc78c4869-hs59j 1/1 Running 0 58s
httpd-app-6dc78c4869-lp4hs 1/1 Running 0 58s
httpd-app-6dc78c4869-z9mc9 1/1 Running 0 2m
[root@k8s-master1 ~]#
[root@k8s-master1 ~]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
httpd-svc NodePort 10.254.122.142 <none> 80:8840/TCP 2m
kubernetes ClusterIP 10.254.0.1 <none> 443/TCP 2d
[root@k8s-master1 ~]#
[root@k8s-master1 ~]# kubectl describe svc httpd-svc
Name: httpd-svc
Namespace: default
Labels: <none>
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"name":"httpd-svc","namespace":"default"},"spec":{"ports":[{"port":80}],"selector":{"a...
Selector: app=httpd-app
Type: NodePort
IP: 10.254.122.142
Port: <unset> 80/TCP
TargetPort: 80/TCP
NodePort: <unset> 8840/TCP
Endpoints: 172.30.14.2:80,172.30.52.2:80,172.30.92.2:80 + 2 more...
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
[root@k8s-master1 ~]#
集群跑起来了。
转载于:https://blog.51cto.com/goome/2167926