- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
环境:
Kubernetes version: v1.16.3
OS: CentOS 7
Kernel: Linux k8s02-master01 3.10.0-1062.4.3.el7.x86_64 #1 SMP Wed Nov 13 23:58:53 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
发生了什么:
我有一个 Wordpress 部署,它运行一个从自定义 Apache/Wordpress 镜像构建的容器。该图像公开端口 8080 而不是 80 (下面的 Dockerfile)。 Pod 通过 Traefik 反向代理暴露给世界。一切正常,无需任何事件或就绪检查。 Pod 准备就绪,可以从 https://www.example.com/ 访问 Wordpress .
我尝试添加 liveness 和 readiness 探测器,但它们都反复失败并显示“连接被拒绝”。当我删除两个探测器并重新应用 Deployment 时,它再次工作。它会一直工作,直到探测器达到故障阈值,此时容器会进入无休止的重启循环并变得无法访问。
POD 事件:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled <unknown> default-scheduler Successfully assigned development/blog-wordpress-5dbcd9c7c7-kdgpc to gg-k8s02-worker02
Normal Killing 16m (x2 over 17m) kubelet, gg-k8s02-worker02 Container blog-wordpress failed liveness probe, will be restarted
Normal Created 16m (x3 over 18m) kubelet, gg-k8s02-worker02 Created container blog-wordpress
Normal Started 16m (x3 over 18m) kubelet, gg-k8s02-worker02 Started container blog-wordpress
Normal Pulled 13m (x5 over 18m) kubelet, gg-k8s02-worker02 Container image "wordpress-test:test12" already present on machine
Warning Unhealthy 8m17s (x35 over 18m) kubelet, gg-k8s02-worker02 Liveness probe failed: Get http://10.244.3.83/: dial tcp 10.244.3.83:80: connect: connection refused
Warning BackOff 3m27s (x27 over 11m) kubelet, gg-k8s02-worker02 Back-off restarting failed container
POD 日志:
WordPress not found in /var/www/html - copying now...
WARNING: /var/www/html is not empty! (copying anyhow)
Complete! WordPress has been successfully copied to /var/www/html
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 10.244.3.83. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 10.244.3.83. Set the 'ServerName' directive globally to suppress this message
[Wed Dec 11 06:39:07.502247 2019] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.3.11 configured -- resuming normal operations
[Wed Dec 11 06:39:07.502323 2019] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
10.244.3.1 - - [11/Dec/2019:06:39:18 +0000] "GET /index.php HTTP/1.1" 301 264 "-" "kube-probe/1.16"
10.244.3.1 - - [11/Dec/2019:06:39:33 +0000] "GET /index.php HTTP/1.1" 301 264 "-" "kube-probe/1.16"
10.244.3.1 - - [11/Dec/2019:06:39:48 +0000] "GET /index.php HTTP/1.1" 301 264 "-" "kube-probe/1.16"
10.244.3.1 - - [11/Dec/2019:06:40:03 +0000] "GET /index.php HTTP/1.1" 301 264 "-" "kube-probe/1.16"
10.244.3.1 - - [11/Dec/2019:06:40:18 +0000] "GET /index.php HTTP/1.1" 301 264 "-" "kube-probe/1.16"
DOCKERFILE ("wordpress-test:test12"):
FROM wordpress:5.2.4-apache
RUN sed -i 's/Listen 80/Listen 8080/g' /etc/apache2/ports.conf;
RUN sed -i 's/:80/:8080/g' /etc/apache2/sites-enabled/000-default.conf;
# RUN sed -i 's/#ServerName www.example.com/ServerName localhost/g' /etc/apache2/sites-enabled/000-default.conf;
EXPOSE 8080
CMD ["apache2-foreground"]
部署:
apiVersion: apps/v1
kind: Deployment
metadata:
name: blog-wordpress
namespace: development
labels:
app: blog
spec:
selector:
matchLabels:
app: blog
tier: wordpress
replicas: 4
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 2
maxUnavailable: 2
template:
metadata:
labels:
app: blog
tier: wordpress
spec:
volumes:
- name: blog-wordpress
persistentVolumeClaim:
claimName: blog-wordpress
containers:
- name: blog-wordpress
# image: wordpress:5.2.4-apache
image: wordpress-test:test12
securityContext:
runAsUser: 65534
allowPrivilegeEscalation: false
capabilities:
add:
- "NET_ADMIN"
- "NET_BIND_SERVICE"
- "SYS_TIME"
resources:
requests:
cpu: "250m"
memory: "64Mi"
limits:
cpu: "500m"
memory: "128Mi"
ports:
- name: liveness-port
containerPort: 8080
readinessProbe:
initialDelaySeconds: 15
httpGet:
path: /index.php
port: 8080
timeoutSeconds: 15
periodSeconds: 15
failureThreshold: 5
livenessProbe:
initialDelaySeconds: 10
httpGet:
path: /index.php
port: 8080
timeoutSeconds: 10
periodSeconds: 15
failureThreshold: 5
env:
# Database
- name: WORDPRESS_DB_HOST
value: blog-mysql
- name: WORDPRESS_DB_NAME
value: wordpress
- name: WORDPRESS_DB_USER
valueFrom:
secretKeyRef:
name: blog-mysql
key: username
- name: WORDPRESS_DB_PASSWORD
valueFrom:
secretKeyRef:
name: blog-mysql
key: password
- name: WORDPRESS_TABLE_PREFIX
value: wp_
- name: WORDPRESS_AUTH_KEY
valueFrom:
secretKeyRef:
name: blog-wordpress
key: auth-key
- name: WORDPRESS_SECURE_AUTH_KEY
valueFrom:
secretKeyRef:
name: blog-wordpress
key: secure-auth-key
- name: WORDPRESS_LOGGED_IN_KEY
valueFrom:
secretKeyRef:
name: blog-wordpress
key: logged-in-key
- name: WORDPRESS_NONCE_KEY
valueFrom:
secretKeyRef:
name: blog-wordpress
key: nonce-key
- name: WORDPRESS_AUTH_SALT
valueFrom:
secretKeyRef:
name: blog-wordpress
key: auth-salt
- name: WORDPRESS_SECURE_AUTH_SALT
valueFrom:
secretKeyRef:
name: blog-wordpress
key: secure-auth-salt
- name: WORDPRESS_LOGGED_IN_SALT
valueFrom:
secretKeyRef:
name: blog-wordpress
key: logged-in-salt
- name: WORDPRESS_NONCE_SALT
valueFrom:
secretKeyRef:
name: blog-wordpress
key: nonce-salt
- name: WORDPRESS_CONFIG_EXTRA
value: |
define('WPLANG', 'fr_FR');
define('WP_CACHE', false);
define('WP_MEMORY_LIMIT', '64M');
volumeMounts:
- name: blog-wordpress
mountPath: "/var/www/html/wp-content"
部署服务:
apiVersion: v1
kind: Service
metadata:
name: blog-wordpress
namespace: development
labels:
app: blog
spec:
ports:
- protocol: TCP
port: 80
targetPort: 8080
selector:
app: blog
tier: wordpress
type: ClusterIP
TRAEFIK 入口:
##
# HTTP
##
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: blog
namespace: development
spec:
entryPoints:
- http
routes:
- match: Host(`example.com`)
kind: Rule
services:
- name: blog-wordpress
port: 80
middlewares:
- name: redirect-to-https
namespace: kube-system
---
##
# HTTPS
##
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: blog-https
namespace: development
spec:
entryPoints:
- https
routes:
- match: Host(`example.com`) && PathPrefix(`/`)
kind: Rule
services:
- name: blog-wordpress
port: 80
tls:
certResolver: letsencrypt
谢谢!
最佳答案
对于任何感兴趣的人,我已经设法解决了这个问题。
由于 Wordpress 强制我的域名 example.com,我从 Wordpress 收到了 301 重定向响应。通过为特定请求禁用 Wordpress 规范重定向功能解决了此问题 http://POD_IP:8080/index.php .
方法如下:
将 Pod IP 地址添加为环境变量:
- name: K8S_POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
创建了一个带有自定义 redirect_canonical 过滤器的 Wordpress 插件,可防止 Wordpress 重定向 http://POD_IP:8080/index.php :
<?php
/**
* Plugin Name: Kubernetes Liveness Probe Exception
*/
add_filter('redirect_canonical', function($redirect_url, $requested_url) {
$K8S_POD_IP = getenv('K8S_POD_IP');
$LIVENESS_URL = "http://" . $K8S_POD_IP . ":8080/index.php";
if ($requested_url == $LIVENESS_URL) {
return $requested_url;
}
return $redirect_url;
}, 10, 2);
关于wordpress - Kubernetes HTTP active 探测失败并显示 "connection refused",即使 URL 在没有它的情况下也能正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59280829/
这个问题已经有答案了: AWS RDS How to set up a MySQL Database (1 个回答) 已关闭 6 年前。 我有一个AWS Elastic Beanstalk实例 Tom
我正在 Mean.js 版本 4.2 上运行 npm test,它在 Protractor e2e 测试中给出了“连接被拒绝”错误。我尝试更新 Selenium 像 this says to.现在它的
我购买了一台服务器(新加坡地区,512 MB RAM)我试图在该服务器中设置单节点集群。我从这个 link当我检查 $ sudo service Cassandra status它正在显示 nodet
我正在使用 spring cloud 来配置微服务。我使用 Jhipster 来生成应用程序。 我有三个应用程序 JHipster-Registry、Gateway 和 admin 应用程序 所有三个
我有 2 个 java 文件 Server.java 和 Client.java。两者都在不同的容器中。 DOCKER 文件:我用于服务器的 dockerfile(在名为“Server”的文件夹中)是
客户端应用程序将 json 数据发送到 localhost:8080 上的服务器,该数据打包并作为 Docker 镜像运行。使用 Postman chrome 应用程序手动发送 json 时,服务器工
我正在尝试关注 celery tutorial ,但是当我运行 python manage.py celeryd 时遇到了一个问题:我的 RabbitMQ 服务器(安装在我开发箱的虚拟机上)不允许我的
我清理了~/.ivy2/cache目录。 我的project/plugins.sbt文件: $ cat project/plugins.sbt // Comment to get more infor
ELK 与销售人员 URL:http://localhost:9200/>, :error_type=>LogStash::Outputs::ElasticSearch::HttpClient::Po
我正在另一个容器中使用 Dockerize spring boot 应用程序和 redis。 我使用 docker compose 在同一网络中运行两个容器,这是我的 docker-compose.y
我试图从我的应用程序访问 Rest API。当该 API 不在线时,我的应用程序发生了上述错误。我正在使用 Spring Boot 。我想知道,有什么方法可以在访问该网址之前检查该网址的可用性。 S
在我的 flutter 应用程序中,我使用 flask 服务器进行测试。我启动了我的服务器并在我的 flutter 应用程序中运行 API url。但是 SocketException: Connec
我正在 Mac 上的 IntelliJ 中设置远程调试器。我没有做任何修改就遵循了模板。然后我单击“调试 xxx”按钮。表明 "Error running 'Remote Debugger': Una
我有一个 linux box,jenkins 服务器在上面运行并从 git 中拉取脚本并开始执行 我有一台 Windows 电脑,我从它打开 jenkins url 说 xyz:8080 并尝试从我的
我在 tomcat 7.50 上有一个应用程序,在单个请求上工作正常,但在许多同时请求 (~1200) 上我得到: 2014-11-02 11:22:48,485 ERROR [MONITOR-AG
当我尝试重新配置我的 gitlab 实例时,出现了这个错误。sudo gitlab-ctl reconfigure 工作正常但是当我尝试启动 gitlab 时我看到 502 错误并且当我跟踪日志时我看
我在 3 个 n1-standard-4 GKE 实例上运行了大约 200 个 pod。流量水平较低,因此每台机器上都有大量备用 CPU 和 RAM。通常当服务尝试相互连接时,连接失败并显示“CONN
我在unbundu机器中使用JMeter设置了分布式负载测试环境。 ->主站:系统运行JMeter GUI,控制每个从站。 ->从站:运行jmeter-server的系统,从主站接收命令,并向被测服务
我需要帮助来解决被拒绝的状态。我查看了 named.conf,一切正常。 我什至把allow-query改成了any,原来是localhost。 dig xxx.com @ns1.xxx.com ;
我正在使用Laravel。当我dd($request->all())时,其中的数据涉及文件和其他一些数据。它返回错误 [2019-02-22 19:40:24] local.ERROR: stream
我是一名优秀的程序员,十分优秀!