--- apiVersion: apps/v1 kind: StatefulSet metadata: name: nginx-material namespace: pro labels: app: nginx-material spec: serviceName: nginx-material replicas: 2 selector: matchLabels: app: nginx-material template: metadata: labels: app: nginx-material spec: terminationGracePeriodSeconds: 180 dnsPolicy: ClusterFirstWithHostNet dnsConfig: nameservers: - 223.5.5.5 - 10.26.22.50 - 10.26.22.150 initContainers: - name: init image: hub.evbj.easou.com/dev/busybox command: [ "chmod","777","-R","/data" ] imagePullPolicy: IfNotPresent volumeMounts: - name: volume mountPath: /data #nodeSelector: # app.touchrs: touchrs # affinity: # podAntiAffinity: # preferredDuringSchedulingIgnoredDuringExecution: # - weight: 100 # podAffinityTerm: # labelSelector: # matchExpressions: # - key: app # operator: In # values: # - nginx-material # topologyKey: kubernetes.io/hostname containers: - name: nginx-material image: nginx:1.14.2 imagePullPolicy: IfNotPresent ports: - containerPort: 80 name: port volumeMounts: - name: volume mountPath: /data - name: nginx-material-config mountPath: /etc/nginx/nginx.conf subPath: nginx.conf readinessProbe: tcpSocket: port: 80 initialDelaySeconds: 40 periodSeconds: 15 # - image: hub.evbj.easou.com/pro/filebeat:7.13.3 # imagePullPolicy: IfNotPresent # name: filebeat # volumeMounts: # - name: volume #日志同时挂载在nginx和filebeat中 # mountPath: /data # - name: filebeat-config # mountPath: /usr/share/filebeat/filebeat.yml # subPath: filebeat.yml volumes: - name: nginx-material-config configMap: name: nginx-material-config items: - key: nginx.conf path: nginx.conf volumeClaimTemplates: - metadata: name: volume spec: accessModes: [ "ReadWriteOnce" ] storageClassName: ceph-block resources: requests: storage: 100Gi --- apiVersion: v1 kind: Service metadata: name: nginx-material-svc namespace: pro labels: app: nginx-material-svc spec: type: NodePort ports: - port: 80 targetPort: 80 name: "main" selector: app: nginx-material --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: nginx-material-ingress namespace: pro spec: rules: - host: material.appeasou.com http: paths: - path: / pathType: Prefix backend: service: name: nginx-material-svc port: number: 8080 ingressClassName: nginx --- apiVersion: v1 kind: ConfigMap metadata: name: nginx-material-config namespace: pro data: nginx.conf: | user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; }