swoft-cloud/swoft

求一份k8s安装的yaml文件写法

Open

#1 329 ouverte le 15 juil. 2020

Voir sur GitHub
 (0 commentaires) (0 réactions) (2 assignés)PHP (850 forks)batch import
help wantedquestion: deplyswoft: config

Métriques du dépôt

Stars
 (5 572 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

自己写的有些问题

【问题】: 1、k8s sowft项目 pod ip地址能正常访问 2、k8s swoft项目 集群ip地址不能正常访问 3、k8s swoft项目 ingress 域名不能正常访问 4、其他类型的pod如nginx或者gitlab等集群项目上述三点均是正常的,所有排除是k8s环境集群网络配置不当 【yaml文件】:

apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: qfx # 命名空间
  name: swoft-dep # deployment名称
spec:
  replicas: 5 #容器个数
  selector:
    matchLabels:
      name: swoft-pod #标签名称
  template:
    metadata:
      labels:
        name: swoft-pod #容器标签名称
    spec:
      tolerations:
      - key: "node.kubernetes.io/unreachable"
        operator: "Exists"
        effect: "NoExecute"
        tolerationSeconds: 2
      - key: "node.kubernetes.io/not-ready"
        operator: "Exists"
        effect: "NoExecute"
        tolerationSeconds: 2
      containers:
      - name: swoft-pod
        image: registry.cn-shanghai.aliyuncs.com/qh_kube/swoft:v2
        imagePullPolicy: IfNotPresent
        #command: ["cd","/var/www/swoft"]
        #command: ["composer","install"]
        #command: ["composer","clearcache"]
        #command: ["php","/var/www/swoft/bin/swoft","http:start"]
        #command: ["cd","/var/www/swoft","composer","install","composer","clearcache","php","/var/www/swoft/bin/swoft","http:start","php","/var/www/swoft/bin/swoft","rpc:start"]
        command: ['sh']
        args:
        - "-c" 
        - |
          php /var/www/swoft/bin/swoft http:start
          php /var/www/swoft/bin/swoft rpc:start
        ports:
        - name: http
          containerPort: 18306 #容器内部端口
#        - name: tcp
#          containerPort: 18307 #容器内部端口
        volumeMounts:
        - name: html
          mountPath: /var/www
      volumes:
      - name: html
        persistentVolumeClaim:
          claimName: swoft-pvc
---
apiVersion: v1
kind: Service
metadata:
  namespace: qfx
  name: swoft-svc
spec:
  ports:
  - port: 18306
    targetPort: 80 
  selector:
    name: swoft-pod
---
#apiVersion: v1
#kind: Service
#metadata:
#  namespace: qfx
#  name: swoftrpc-svc
#spec:
#  ports:
#  - port: 18307
#    targetPort: 18307
#  selector:
#    name: swoft-pod
#  type: ClusterIP
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: swoft-ingress
  namespace: qfx
  annotations:
    kubernetes.io/ingress.class: traefik
spec:
  rules:
  - host: swoft.com
    http:
      paths:
      - path: /test
        backend:
          serviceName: swoft-svc
          servicePort: 80

Guide contributeur