我正在嘗試在 eks 集群上部署這個基本的 nginx 映像,但在嘗試訪問公共 IP 時似乎無法訪問它。我正在使用官方 EKS 模塊并進行了以下設定:

我還使用 k8s 提供程式進行了此部署設定:
resource "kubernetes_deployment" "helloworld" {
metadata {
name = "helloworld"
}
spec {
replicas = 2
selector {
match_labels = {
app = "helloworld"
}
}
template {
metadata {
labels = {
app = "helloworld"
}
}
spec {
container {
name = "nginx"
image = "nginx"
port {
container_port = 80
}
}
}
}
}
}
resource "kubernetes_service" "example" {
metadata {
name = "helloworld"
}
spec {
selector = {
app = "helloworld"
}
session_affinity = "ClientIP"
port {
port = 8080
target_port = 80
}
type = "NodePort"
}
}
當我去檢查kubectl describe pods時,我被告知無法訪問該服務:

我在這里錯過了什么?
uj5u.com熱心網友回復:
在嘗試訪問公共 IP 時訪問它
使用負載均衡器服務公開您的 nginx:
kubectl expose deployment helloworld --port 80 --target-port 80 --name helloworld-service --type LoadBalancer
獲取外部IP:
kubectl get services helloworld-service
做一個curl <external IP>你的 helloworld nginx 應該回應你。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/359002.html
標籤:亚马逊网络服务 Kubernetes 地形
