8.全局验证
验证测试
创建一个nginx的service试一下集群是否可用
[root@k8s bin]# kubectl run nginx --replicas=1 --labels="run=load-balancer-example" --image=nginx --port=80
pod "nginx" created
- k8s 1.18已经不再会创建
deployment
了,取而代之的是直接创建pod
[root@k8s bin]# kubectl expose pod nginx --type=NodePort --name=example-service
service "example-service" exposed
此时pod已经跑起来了
[root@k8s bin]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 1 26h
[root@k8s bin]# kubectl describe svc example-service
Name: example-service
Namespace: default
Labels: run=load-balancer-example
Annotations: <none>
Selector: run=load-balancer-example
Type: NodePort
IP: 10.254.219.204
Port: <unset> 80/TCP
TargetPort: 80/TCP
NodePort: <unset> 31081/TCP
Endpoints: 172.17.0.2:80
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
[root@k8s bin]# curl "10.254.219.204:80"
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
安装完成!