微信对接时,会要求对接方,将某个校验文件,放到服务器,以便其验证服务器、域名等信息的正常
此时,可以利用 k8s 的 config map,将 ConfigMap 中某个 key 的 value 映射为 nginx 下的 文件名及文件内容
而,无须将文件放到某个特定的服务里
# 创建 namespace,如 tmp # 并修改以下配置中的 namespace # 创建 ConfigMap --- apiVersion: v1 kind: ConfigMap metadata: # 修改namespace namespace: tmp name: txt data: # 修改 key,value # 其中, # key 为 文件名 # value 为 文件内容 FWdJ6SLVde.txt: "70976dc348062015aaecd04c4fe393c6" # 部署nginx,并将 ConfigMap 挂载成文件 --- apiVersion: v1 kind: Service metadata: # 修改namespace namespace: tmp name: txt-svc labels: app: txt-svc spec: ports: - port: 80 targetPort: http protocol: TCP name: http selector: app: txt --- apiVersion: apps/v1 kind: Deployment metadata: # 修改namespace namespace: tmp name: txt spec: selector: matchLabels: app: txt replicas: 1 template: metadata: labels: app: txt spec: containers: - name: txt-nginx # 根据情况修改镜像地址 image: nginx:latest ports: - containerPort: 80 name: http volumeMounts: - name: txt mountPath: /usr/share/nginx/html readOnly: true volumes: - name: txt configMap: # 这个是 ConfigMap 的名称 name: txt items: # 将 ConfigMap 中某个 key 的 value 映射为 文件及文件内容 - key: FWdJ6SLVde.txt path: FWdJ6SLVde.txt # 配置ingress --- apiVersion: extensions/v1beta1 kind: Ingress metadata: # 修改namespace namespace: tmp name: txt-ingress spec: rules: # 修改为学校的根域名 - host: txt.paas.xxx.edu.cn http: paths: # 修改path,对应某个文件路径 - path: /FWdJ6SLVde.txt backend: serviceName: txt-svc servicePort: http