igress+nginx部署
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了igress+nginx部署相关的知识,希望对你有一定的参考价值。
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部署的主要内容,如果未能解决你的问题,请参考以下文章