k8s部署nginx集群
环境:
两台虚拟机,
10.10.20.203 部署docker、etcd、flannel、kube-apiserver、kube-controller-manager、kube-scheduler
10.10.20.206 部署docker、flannel、kubelet、kube-proxy
1、创建nginx-rc.yaml
apiVersion: v1
kind: ReplicationController
metadata:name: nginx-controller
spec:replicas: 2selector:name: nginxtemplate:metadata:labels:name: nginxspec:containers:- name: nginximage: nginxports:- containerPort: 80
2、创建nginx-service-nodeport.yaml
apiVersion: v1
kind: Service
metadata:name: nginx-service-nodeport
spec:ports:- port: 8000targetPort: 80protocol: TCPtype: NodePortselector:name: nginx
3、创建pod
kubectl create -f nginx-rc.yaml
4、创建service
kubectl create -f nginx-service-nodeport.yaml
5、查看pod
[root@k8s-master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-controller-v40nj 1/1 Running 1 1h
nginx-controller-zxdzh 1/1 Running 1 1h
[root@k8s-master ~]# kubectl describe pod nginx-controller-v40nj
Name: nginx-controller-v40nj
Namespace: default
Node: k8s-slave1-206/60.19.29.21
Start Time: Thu, 11 Aug 2016 19:02:20 -0700
Labels: name=nginx
Status: Running
IP: 10.0.83.3
Controllers: ReplicationController/nginx-controller
Containers:nginx:Container ID: docker://269adc9b693aba0356ba18e4253c2b498fc7b7a8ce0af83857fcfd6b70e6ef03Image: nginxImage ID: docker://sha256:0d409d33b27e47423b049f7f863faa08655a8c901749c2b25b93ca67d01a470dPort: 80/TCPState: RunningStarted: Thu, 11 Aug 2016 20:49:27 -0700Last State: TerminatedReason: CompletedExit Code: 0Started: Thu, 11 Aug 2016 19:03:44 -0700Finished: Thu, 11 Aug 2016 20:12:12 -0700Ready: TrueRestart Count: 1Environment Variables: <none>
Conditions:Type StatusInitialized TrueReady TruePodScheduled True
No volumes.
QoS Tier: BestEffort
Events:FirstSeen LastSeen Count From SubobjectPath Type Reason Message--------- -------- ----- ---- ------------- -------- ------ -------5m 5m 1 {kubelet k8s-slave1-206} spec.containers{nginx} Normal Pulling pulling image "nginx"5m 5m 2 {kubelet k8s-slave1-206} Warning MissingClusterDNS kubelet does not have ClusterDNS IP configured and cannot create Pod using "ClusterFirst" policy. Falling back to DNSDefault policy.5m 5m 1 {kubelet k8s-slave1-206} spec.containers{nginx} Normal Pulled Successfully pulled image "nginx"5m 5m 1 {kubelet k8s-slave1-206} spec.containers{nginx} Normal Created Created container with docker id 269adc9b693a5m 5m 1 {kubelet k8s-slave1-206} spec.containers{nginx} Normal Started Started container with docker id 269adc9b693a
6、查看service
[root@k8s-master ~]# kubectl get service
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes 10.254.0.1 <none> 443/TCP 16h
nginx-service-nodeport 10.254.29.72 <nodes> 8000/TCP 49m
[root@k8s-master ~]# kubectl describe service nginx-service-nodeport
Name: nginx-service-nodeport
Namespace: default
Labels: <none>
Selector: name=nginx
Type: NodePort
IP: 10.254.29.72
Port: <unset> 8000/TCP
NodePort: <unset> 31152/TCP
Endpoints: 10.0.83.2:80,10.0.83.3:80
Session Affinity: None
No events.
7、测试service是否好用
因为service使用的是NodePort方式,所以在任何一个节点访问31152这个端口都可以访问nginx
$ curl 10.10.20.203:31152
<!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>
$ curl 10.10.20.206:31152
<!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>
k8s部署nginx集群相关推荐
- K8S 部署rabbitmq集群
K8S 部署rabbitmq集群 版本介绍 名称 版本 k8s 1.18 rabbitmq 3.8 命名空间:rabbitmq 我这里已经建立 configmap 配置文件 [root@k8s-mas ...
- docker 部署rabbitmq,k8s部署rabbitmq集群,跟踪和监控rabbitmq
全栈工程师开发手册 (作者:栾鹏) 架构系列文章 rabbit原理和架构可以参考https://blog.csdn.net/luanpeng825485697/article/details/8208 ...
- .net core部署Nginx集群
文章目录 一.Nginx是什么? 二.使用步骤 1.Linux上安装Nginx 2.查看nginx是否安装成功 3.启动nginx 4.检验 一.Nginx是什么? Nginx是一个高性能的HTTP和 ...
- Docker部署Nginx集群
背景 Nginx作为负载均衡工具在企业开发中,特别是分布式开发中十分常见,下面来看看腾讯云服务器中在CentOS7.6系统中使用Docker部署Nginx集群的具体步骤 环境 Linux:CentOS ...
- k8s部署kafka集群
前言 环境:centos 7.9 k8s集群.zookeeper集群 本篇将在k8s中部署kafka集群,kafka依赖zookeeper集群,zookeeper集群我们已经搭建好了,可以参考http ...
- kubernetes入门到精通(二):k8s部署Tomcat集群,基于NTFS协议的文件集群共享,Service提供负载均衡,端口转发工具Rinetd配置外部访问
首先,配置 Docker 镜像加速服务 登录阿里云账号,进入控制台 -> 容器镜像服务 (不需要有阿里云的服务器,只要注册账号即可) 在两台 node 节点上配置好阿里云的镜像加速. 重启一下 ...
- k8s部署eureka集群
在k8s集群中通过CICD进行部署Eureka集群 一.前言 普通后端如果想要同时起多个服务来进行负载均衡,可以通过部署Deployment并调整Pod的数量,然后交由Service来代理这些Pod, ...
- k8s部署redis集群
K8S部署Redis Cluster集群 kubernetes部署单节点redis: https://www.cnblogs.com/zisefeizhu/p/14282299.html Redis ...
- 使用K8S部署zookeeper集群
1.目的: 本次的目的是通过使用k8s搭建一个三节点的zookeeper集群,因为zookeeper集群需要用到存储,所以我们需要准备三个持久卷(Persistent Volume) 简称就是PV. ...
最新文章
- 【转载】说说大型高并发高负载网站的系统架构
- 用反向传导做分子模拟:苯胺(C6H5NH2)和硝基苯(C6H5NO2)
- 跑faster rcnn测试时遇到错误Attribute Error: 'NoneType' object has no attribute 'astype'
- WARNING:Your password has expired --linux 用户密码过期
- SAP Hybris里搜索显示结果的实现原理
- Lombok中@Data注解 @ToString注解 @NoArgsConstructo注解 @AllArgsConstructor注解
- 数据全裸时代,你的隐私有多容易获取?
- 前端 优化 json stringify 在IE浏览器的兼容性 按钮点击不生效
- Java传参是字节还是字符串好_深入分析java传参
- atitit uke产品线 attilax总结.docx 1. 知识聚合 知识检索 产品线	1 2. 爬虫产品线	1 3. 发帖机产品线	1 4. 发动机产品线	1 5. O2o产品线(旅游
- 如何在iPhone上安装Skype?
- node.js 爬取腾讯地图API全国行政区数据
- 建模助手 —『 CAD图层管理 』Revit视图干净清爽
- 详解机器学习算法基础--K近邻算法
- 华为2019.8.22笔试题
- 【ZZULIOJ】1097: 计算平均成绩(函数专题)
- 金庸:为什么历史上没有一个国家能成功吞并中国?
- 计算机换色带技巧,打印机色带维护技巧
- Illumination Normalization Based on Weber’s Law With Application to Face Recognition
- 内涵一下我参加过的那些竞赛。
热门文章
- 如何在 jetbrick-template 中使用 debug函数?
- 网管,待遇为何如此差劲?
- CodeForces - 1408F Two Different(构造+分治)
- CodeForces - 1350E Orac and Game of Life(bfs)
- CodeForces - 1305C Kuroni and Impossible Calculation(鸽巢原理)
- bootstrap 图片预览_教你简单用Photoshop制作GIF图片
- MMDetection-简介
- 深度学习项目-人群密度估计
- C++读图片——Mac下对于bmp文件读写读取过大的解决方案
- mysql协议重传_TCP协议详解