码迷,mamicode.com
首页 > 其他好文 > 详细

igress+nginx部署

时间:2019-03-09 23:12:35      阅读:297      评论:0      收藏:0      [点我收藏+]

标签:contain   selector   nod   tor   mes   Nginx部署   api   deploy   创建   

k8s-部署nginx

apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 1 # tells deployment to run 2 pods matching the template
template: # create pods using pod definition in this template
metadata:
labels:
app: nginx
spec:
nodeSelector:
kubernetes.io/hostname: k8s-n1 #指定node运行
containers:

  • name: nginx
    image: nginx:1.7.9
    ports:
  • containerPort: 80
    volumeMounts: #pod 内部文配置文件映射到本机
  • name: nginxconf
    mountPath: /etc/nginx/nginx.conf
  • name: nginxconfd
    mountPath: /etc/nginx/conf.d
  • name: nginxlogs
    mountPath: /var/log/nginx/log
    volumes: #物理机文件目录
  • name: nginxconf
    hostPath:
    path: /data/nginx/nginx.conf
  • name: nginxconfd
    hostPath:
    path: /data/nginx/conf.d
  • name: nginxlogs
    hostPath:
    path: /data/nginx/logs
    创建服务
    apiVersion: v1
    kind: Service
    metadata:
    name: nginx-server
    labels:
    name: nginx-server
    spec:
    ports:
  • port: 80
    nodePort: 80
    selector:
    app: nginx
    type: NodePort # 这个服务中使用了nodePort 意思是将服务暴露出去这样就可外部访问了

igress+nginx部署

标签:contain   selector   nod   tor   mes   Nginx部署   api   deploy   创建   

原文地址:https://blog.51cto.com/8175747/2360425

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!