我正在向我的 Kubernetes 集群添加一个 NextJS 前端。我添加了以下文件:
apiVersion: apps/v1
kind: Deployment
metadata:
name: client-depl
spec:
replicas: 1
selector:
matchLabels:
app: client
template:
metadata:
labels:
app: client
spec:
containers:
- name: client
image: ldco2016/client
---
apiVersion: v1
kind: Service
metadata:
name: client-srv
spec:
selector:
app: client
ports:
- name: client
protocol: TCP
port: 3000
targetPort: 3000
到我的infra/k8s/
目录,然后ingress-srv.yml
像这样重新配置:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-service
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: "true"
spec:
rules:
- host: ticketing.dev
http:
paths:
- path: /api/users/?(.*)
backend:
serviceName: auth-srv
servicePort: 3000
- path: /?(.*)
backend:
serviceName: client-srv
servicePort: 3000
和skaffold.yml
文件:
apiVersion: skaffold/v2alpha3
kind: Config
deploy:
kubectl:
manifests:
- ./infra/k8s*
build:
local:
push: false
artifacts:
- image: ldco2016/auth
context: auth
docker:
dockerfile: Dockerfile
sync:
manual:
- src: "src/**/*.ts"
dest: .
- image: ldco2016/client
context: client
docker:
dockerfile: Dockerfile
sync:
manual:
- src: "**/*.js"
dest: .
当我运行skaffold dev
它时,它挂在这里:
starting deploy...
- deployment.apps/auth-depl created
- service/auth-srv created
- deployment.apps/auth-mongo-depl created
- service/auth-mongo-srv created
- deployment.apps/client-depl created
- service/client-srv created
- ingress.extensions/ingress-service created
Waiting for deployments to stabilize...
- deployment/auth-depl: waiting for rollout to finish: 0 of 1 updated replicas are available...
- deployment/auth-mongo-depl: waiting for rollout to finish: 0 of 1 updated replicas are available...
- deployment/client-depl: waiting for rollout to finish: 0 of 1 updated replicas are available...
- deployment/client-depl is ready. [2/3 deployment(s) still pending]
- deployment/auth-mongo-depl is ready. [1/3 deployment(s) still pending]
有任何想法吗?
我也在运行 Docker 桌面和 Kubernetes。由于这是一个微服务应用程序,我认为 Kubernetes 可能需要更多资源。我试图添加更多资源,但这并没有解决问题。