gpt4 book ai didi

kubernetes - Kubernetes:为什么我的部署缺少端点?

转载 作者:行者123 更新时间:2023-12-02 12:04:55 25 4
gpt4 key购买 nike

我倾向于Kubernetes,已将 secret 应用到我先前运行的部署中。现在,我遇到了无法运行我的网站的问题

kubectl get ep -o wide
NAME ENDPOINTS AGE
hello-node 172.17.0.8:8080 2d21h
kubernetes 192.168.99.101:8443 3d
tomcat-deployment 172.17.0.10:8080,172.17.0.6:8080,172.17.0.7:8080 + 1 more... 2d16h
wordpress 24h
wordpress-mysql 172.17.0.15:3306 24h

描述输出
Name:               wordpress
Namespace: default
CreationTimestamp: Tue, 12 Mar 2019 09:10:24 +0100
Labels: app=wordpress
Annotations: deployment.kubernetes.io/revision: 1
kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"apps/v1beta2","kind":"Deployment","metadata":{"annotations":{},"labels":{"app":"wordpress"},"name":"wordpress","namespace":...
Selector: app=wordpress,tier=frontend
Replicas: 1 desired | 1 updated | 1 total | 0 available | 1 unavailable
StrategyType: Recreate
MinReadySeconds: 0
Pod Template:
Labels: app=wordpress
tier=frontend
Containers:
wordpress:
Image: wordpress:4.8-apache
Port: 80/TCP
Host Port: 0/TCP
Environment:
WORDPRESS_DB_HOST: wordpress-mysql
WORDPRESS_DB_PASSWORD: <set to the key 'password' in secret 'mysql-pass'> Optional: false
Mounts:
/var/www/html from wordpress-persistent-storage (rw)
Volumes:
wordpress-persistent-storage:
Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
ClaimName: wp-pv-claim
ReadOnly: false
Conditions:
Type Status Reason
---- ------ ------
Progressing True NewReplicaSetAvailable
Available False MinimumReplicasUnavailable
OldReplicaSets: <none>
NewReplicaSet: wordpress-dccb8668f (1/1 replicas created)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ScalingReplicaSet 7m37s deployment-controller Scaled up replica set wordpress-dccb8668f to 1

我删除了先前的部署并创建了新的部署,因为在运行secret cli时会发生一些问题。我不明白这一点,为什么缺少终点?
它还显示我的副本不可用,如何解决此问题?我创建了部署
apply -f ./deployment.yaml

pod 正在运行
wordpress-dccb8668f-4j6wg            1/1     Running            29         137m
wordpress-mysql-7d4fc77fdc-fmhdh 1/1 Running 0 141m

得到svc -o宽
wordpress           LoadBalancer   10.102.29.45     <pending>     80:31262/TCP     26h     app=wordpress,tier=frontend
wordpress-mysql ClusterIP None <none> 3306/TCP 26h app=wordpress,tier=mysql

编辑
我按照S.Schenkel的建议更改了deployment.yaml
apiVersion: v1
kind: Service
metadata:
name: wordpress
labels:
app: wordpress
spec:
ports:
- port: 80
selector:
app: wordpress
tier: frontend
type: NodePort

我仍然有同样的问题。
minikube service wordpress --url
http://192.168.99.101:31262
miki@miki:~$ curl http://192.168.99.101:31262
curl: (7) Failed to connect to 192.168.99.101 port 31262: Connection refused
miki@miki:~$

如果有人想重现示例

https://github.com/LevelUpEducation/kubernetes-demo/tree/master/Advanced%20Kubernetes%20Usage/Secrets


NAME                TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE     SELECTOR
hello-node LoadBalancer 10.104.141.138 <pending> 8080:31321/TCP 3d3h app=hello-node
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 3d6h <none>
tomcat-deployment LoadBalancer 10.107.218.19 <pending> 8080:32688/TCP 2d22h app=tomcat
wordpress NodePort 10.102.29.45 <none> 80:31262/TCP 30h app=wordpress,tier=frontend
wordpress-mysql ClusterIP None <none> 3306/TCP 30h app=wordpress,tier=mysql

pod
wordpress-dccb8668f-gk2hn            0/1     CrashLoopBackOff   27         126m    172.17.0.8    minikube   <none>           <none>
wordpress-mysql-7d4fc77fdc-fmhdh 1/1 Running 1 6h23m 172.17.0.19 minikube <none> <none>

CrashLoopBackOff意味着什么?

最佳答案

我刚刚在minikube中复制了您的案件,并能够获得wordpress服务

这是分步说明:

  • 为MySQL部署创建 secret
  • kubectl create secret generic mysql-pass --from-literal=password=password
  • 首先部署MySQL
  • 部署wordpress
  • 将wordpress服务类型从type: LoadBalancer更改为type: NodePort
  • kubectl edit svc wordpress
  • 确保所有 pods 都在运行
  • kubectl get pods -o wide
  • 如果 pods 没有问题,请尝试 curl 服务
  • curl -v $(minikube service --url wordpress)
    你应该有这样的东西
    sukhoversha@minikube:~$ curl -v $(minikube service --url wordpress)
    * Rebuilt URL to: http://192.168.99.100:32144/
    * Trying 192.168.99.100...
    * Connected to 192.168.99.100 (192.168.99.100) port 32144 (#0)
    > GET / HTTP/1.1
    > Host: 192.168.99.100:32144
    > User-Agent: curl/7.47.0
    > Accept: */*
    >
    < HTTP/1.1 302 Found
    < Date: Tue, 12 Mar 2019 15:26:23 GMT
    < Server: Apache/2.4.10 (Debian)
    < X-Powered-By: PHP/5.6.32
    < Expires: Wed, 11 Jan 1984 05:00:00 GMT
    < Cache-Control: no-cache, must-revalidate, max-age=0
    < Location: http://192.168.99.100:32144/wp-admin/install.php
    < Content-Length: 0
    < Content-Type: text/html; charset=UTF-8
    <
    * Connection #0 to host 192.168.99.100 left intact

    关于kubernetes - Kubernetes:为什么我的部署缺少端点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55116950/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com