k8s-应用快速入门(ma)
[root@k8s-master ~]# kubectl run nginx-deploy --image=nginx:1.14-alpine --port=80 --replicas=1
deployment "nginx-deploy" created
[root@k8s-master ~]# kubectl expose deployment nginx-deploy --name nginx --port=80 --target-port=80 --protocol=TCP ###target-port等于上图pod_port,--port等于service_port
service "nginx" exposed
[root@k8s-master ~]# kubectl run busybox-client --image=busybox --replicas=1 -it --restart=Never ###启动一个busybox pod ,作为客户端
If you don't see a command prompt, try pressing enter.
/ #
[root@k8s-master ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
busybox-client 1/1 Running 0 1d
frontend-7t8x9 1/1 Running 0 2d
frontend-8jf5h 1/1 Running 0 2d
frontend-vmh7n 1/1 Running 0 2d
nginx-deploy-5b595999-rd9cx 1/1 Running 0 1d
redis-master-gk58w 1/1 Running 0 2d
redis-slave-sjtvf 1/1 Running 0 2d
redis-slave-znn7x 1/1 Running 0 2d
[root@k8s-master ~]# kubectl exec -it nginx-deploy-5b595999-rd9cx -c nginx-deploy /bin/sh ###进入到客户端
[root@k8s-master src]# kubectl attach po/busybox-client -c busybox-client -it ###启动客户端
/ # cat /etc/resolv.conf
nameserver 10.10.10.2
search default.svc.cluster.local svc.cluster.local cluster.local
options ndots:5
/ # nslookup nginx
Server: 10.10.10.2
Address: 10.10.10.2:53
Name: nginx.default.svc.cluster.local
Address: 10.10.10.18
/ # wget -O - -q http://nginx:80 ####可以解析nginx
<!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>
[root@k8s-node02 ~]# dig -t A nginx.default.svc.cluster.local @10.10.10.2 ; <<>> DiG 9.9.-RedHat-9.9.-.el7_6 <<>> -t A nginx.default.svc.cluster.local @10.10.10.2
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id:
;; flags: qr aa rd ra; QUERY: , ANSWER: , AUTHORITY: , ADDITIONAL: ;; QUESTION SECTION:
;nginx.default.svc.cluster.local. IN A ;; ANSWER SECTION:
nginx.default.svc.cluster.local. IN A 10.10.10.18 ;; Query time: msec
;; SERVER: 10.10.10.2#(10.10.10.2)
;; WHEN: Wed Jun :: EDT
;; MSG SIZE rcvd:
从上可以看到,kube-dns已经安装成功!!!
最新文章
- Mac 下使用homebrew 安装node后全局安装找不到问题
- My first win32 application program
- android系统中自带的一些ThemeStyle
- ANSI_NULLS和QUOTED_IDENTIFIER
- java基础回顾(二)——内部类
- java解析properties文件
- 用JS实现版面拖拽效果
- webAPP前端必备知识
- Majority Element,Majority Element II
- curl的封装
- hdu_3565_Bi-peak Number(数位DP)
- Python_文本操作
- Windonws基本命令手册
- 在go modules里使用go get进行包管理
- [Hive_12] Hive 的自定义函数
- ecmall 学习记录3
- 【python深入】dict和list实现排序:sorted()和lambda的使用
- 洛谷.3690.[模板]Link Cut Tree(动态树)
- [转]JVM内存模型
- 微信赌场——H5棋牌游戏渗透之旅
热门文章
- Java编码辅助工具:Mapstruct—— Java对象转换框架
- 概率图模型(PGM)学习笔记(二)贝叶斯网络-语义学与因子分解
- ip获取位置
- 用HttpClient模拟HTTP的GET和POST请求(转)
- 开源大数据引擎:Greenplum 数据库架构分析
- create-react-app创建项目报错SyntaxError: Unexpected end of JSON input while parsing near &#39;...ttachment";:false,";tar&#39; npm代理
- Gradle 介绍
- RTSP Windows专用播放器EasyPlayer : 稳定、兼容、高效、超低延时
- 九度OJ 1009:二叉搜索树 (二叉树)
- Method invoke 方法