localstack k8s 部署 yaml 和健康检查端点

时间:2021-05-30 12:59:07

标签: kubernetes minikube localstack

我已经设置了 win 10、minikube、docker。 我需要在本地 minikube 中启动 localstack。我没有找到k8s部署yaml。所以我采用了他们在 github 上提供的 docker compose yaml。并创建如下文件:

# disk volume claim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  creationTimestamp: null
  labels:
    com.job.service: localstack-claim0
  name: localstack-claim0
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 100Mi
status: {}
---
# service account
apiVersion: v1
kind: ServiceAccount
metadata:
  name: localstack-account
  labels:
    com.job.service: localstack-service-account
---
# service
apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    com.job.service: localstack-service
  name: localstack-service
spec:
  type: NodePort
  externalTrafficPolicy: Cluster
  ports:
    - name: "edge"
      port: 4566
      targetPort: 4566
    - name: "es"
      port: 4571
      targetPort: 4571
    - name: "ui"
      port: 8080
      targetPort: 8080
  selector:
    com.job.service: localstack-service
status:
  loadBalancer: {}
---
# deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    com.job.service: localstack-deployment
  name: localstack-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      com.job.service: localstack-deployment
  strategy:
    type: Recreate
  template:
    metadata:
      creationTimestamp: null
      labels:
        com.job.service: localstack-deployment
    spec:
      containers:
        - env:
            - name: DATA_DIR
              value: ' '
            - name: DEBUG
              value: ' '
            - name: DOCKER_HOST
              value: tcp://127.0.0.1:2376
            - name: HOST_TMP_FOLDER
            - name: KINESIS_ERROR_PROBABILITY
              value: ' '
            - name: LAMBDA_EXECUTOR
              value: ' '
            - name: PORT_WEB_UI
              value: ' '
            - name: SERVICES
              value: 'sqs'
          image: localstack/localstack
          imagePullPolicy: IfNotPresent
          name: localstack-main
          ports:
            - name: edge
              containerPort: 4566
              protocol: TCP
            - name: es
              containerPort: 4571
              protocol: TCP
            - name: ui
              containerPort: 8080
              protocol: TCP
          livenessProbe:
            failureThreshold: 3
            initialDelaySeconds: 0
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 1
            httpGet:
              path: /health
              port: edge
          readinessProbe:
            failureThreshold: 3
            initialDelaySeconds: 0
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 1
            httpGet:
              path: /health
              port: edge
          resources: {}
          volumeMounts:
            - mountPath: /tmp/localstack
              name: localstack-claim0
      restartPolicy: Always
      serviceAccountName: localstack-account
      volumes:
        - name: localstack-claim0
          persistentVolumeClaim:
            claimName: localstack-claim0
status: {}

但是当我开始使用 kubectl apply -f path_To_yaml 并等待所有服务启动时。我尝试到达运行状况检查端点,但只收到无法连接到主机的异常

我尝试使用 minikube tunnel ,但这没有帮助

可能有人知道如何配置正确的localy?我是 DevOps 的新手

尝试使用 minikube addons enable ingress 但没有帮助我

enter image description here

enter image description here

enter image description here

enter image description here

尝试使用下一个命令手动公开和转发端口

kubectl expose pod localstack-deployment-7667b8d6bf-6mqbp --type=ClusterIP --name=localstack

kubectl port-forward po/localstack-deployment-7667b8d6bf-6mqbp 4566:4566

并连接 aws cli 和 awslocal cli;但同样的结果:无法连接

1 个答案:

答案 0 :(得分:0)

Kubernetes 集群需要有一个入口控制器来将来自外部世界的流量路由到

minikube addons enable ingress

以上将启用入口,当您执行“获取 pods”时,您应该会看到一个有效的入口控制器

NAME                                        READY     STATUS    RESTARTS   AGE
default-http-backend-59868b7dd6-xb8tq       1/1       Running   0          1m
kube-addon-manager-minikube                 1/1       Running   0          3m
kube-dns-6dcb57bcc8-n4xd4                   3/3       Running   0          2m
kubernetes-dashboard-5498ccf677-b8p5h       1/1       Running   0          2m
nginx-ingress-controller-5984b97644-rnkrg   1/1       Running   0          1m
storage-provisioner                         1/1       Running   0          2m

如果这仍然不能解决您的问题, 请发布有关以下 kubectl 命令的其他信息

kubectl describe ingress
kubectl describe service

这些命令的输出可能会帮助您进一步

相关问题