- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我无法使用公共(public) IP 地址公开部署在 AKS 上的 k8s 集群。我正在使用 GitHub Actions 进行部署。以下是我的 .tf 和 deployment.yml 文件;
请查看下面我遇到的错误。
主要.tf
provider "azurerm" {
features {}
}
provider "azuread" {
version = "=0.7.0"
}
terraform {
backend "azurerm" {
resource_group_name = "tstate-rg"
storage_account_name = "tstateidentity11223"
container_name = "tstate"
access_key = "/qSJCUo..."
key = "terraform.tfstate"
}
}
# create resource group
resource "azurerm_resource_group" "aks" {
name = "${var.name_prefix}-rg"
location = var.location
}
}
aks-cluster.tf
resource "azurerm_kubernetes_cluster" "aks" {
name = "${var.name_prefix}-aks"
location = var.location
resource_group_name = var.resourcename
dns_prefix = "${var.name_prefix}-dns"
default_node_pool {
name = "identitynode"
node_count = 3
vm_size = "Standard_D2_v2"
os_disk_size_gb = 30
}
service_principal {
client_id = var.client_id
client_secret = var.client_secret
}
network_profile {
network_plugin = "kubenet"
load_balancer_sku = "Standard"
}
}
nginxlb.tf
# Initialize Helm (and install Tiller)
provider "helm" {
# install_tiller = true
kubernetes {
host = azurerm_kubernetes_cluster.aks.kube_config.0.host
client_certificate = base64decode(azurerm_kubernetes_cluster.aks.kube_config.0.client_certificate)
client_key = base64decode(azurerm_kubernetes_cluster.aks.kube_config.0.client_key)
cluster_ca_certificate = base64decode(azurerm_kubernetes_cluster.aks.kube_config.0.cluster_ca_certificate)
load_config_file = false
}
}
# Add Kubernetes Stable Helm charts repo
data "helm_repository" "stable" {
name = "stable"
url = "https://kubernetes-charts.storage.googleapis.com"
}
# Create Static Public IP Address to be used by Nginx Ingress
resource "azurerm_public_ip" "nginx_ingress" {
name = "nginx-ingress-pip"
location = azurerm_kubernetes_cluster.aks.location
resource_group_name = azurerm_kubernetes_cluster.aks.node_resource_group
allocation_method = "Static"
domain_name_label = var.name_prefix
}
# Install Nginx Ingress using Helm Chart
resource "helm_release" "nginx" {
name = "nginx-ingress"
repository = data.helm_repository.stable.url
#repository = data.helm_repository.stable.metadata.0.name
chart = "nginx-ingress"
# namespace = "kube-system"
namespace = "default"
set {
name = "rbac.create"
value = "false"
}
set {
name = "controller.service.externalTrafficPolicy"
value = "Local"
}
set {
name = "controller.service.loadBalancerIP"
value = azurerm_public_ip.nginx_ingress.ip_address
}
}
还有我的 deployment.yml
apiVersion: v1
kind: Namespace
metadata:
name:
namespace: default
---
apiVersion: v1
kind: Service
metadata:
name: identity-svc
namespace: default
labels:
name: identity-svc
env: dev
app: identity-svc
annotations:
service.beta.kubernetes.io/azure-load-balancer-resource-group: MC_identity-k8s-rg_identity-k8s-aks_westeurope
# nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
loadBalancerIP: 13.95.67.206
type: LoadBalancer ## NodePort,ClusterIP,LoadBalancer --> Ingress Controller:nginx,HAProxy
ports:
- name: http
port: 8000
targetPort: 8000
nodePort: 30036
protocol: TCP
selector:
app: identity-svc
---
apiVersion: v1
data:
.dockerconfigjson: eyJhdXRocyI6eyJpZGVudGl0eXNlcnZpY2UuYXp1cmVjVZWcVpYS2o4QTM3RmsvZEZZbTlrbHQiLCJlbWFpbCI6InN1YmplQHN1YmplLmNvbSIsImF1dGgiOiJ
kind: Secret
metadata:
creationTimestamp: null
name: acr-secret
namespace: default
type: kubernetes.io/dockerconfigjson
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: identity-deploy
namespace: default
labels:
name: identity-app
env: dev
spec:
replicas: 1
selector:
matchLabels:
app: identity-svc
template:
metadata:
namespace: default
labels:
app: identity-svc
spec:
#backoffLimit: 1
imagePullSecrets:
- name: acr-secret
containers:
- name: identitysvc
image: identitysvc.azurecr.io/identitysvc:${{ github.run_id }}
env:
- name: SECRET_KEY
value: ${SECRET_KEY}
- name: DOPPLER_TOKEN
value: ${DOPPLER_TOKEN}
resources:
requests:
cpu: 0.5
memory: "500Mi"
limits:
cpu: 2
memory: "1000Mi"
ports:
- containerPort: 8000
name: http
imagePullPolicy: Always
restartPolicy: Always
以下是 GitHub Actions 日志和 Azure 上的 Kubectl 的错误消息。
GitHub 操作日志;此消息会重复直到超时。
Kubectl 登录 AKS;
kubectl 描述 svc
Name: nginx-ingress-controller
Namespace: default
Labels: app=nginx-ingress
app.kubernetes.io/managed-by=Helm
chart=nginx-ingress-1.41.3
component=controller
heritage=Helm
release=nginx-ingress
Annotations: meta.helm.sh/release-name: nginx-ingress
meta.helm.sh/release-namespace: default
Selector: app.kubernetes.io/component=controller,app=nginx-ingress,release=nginx-ingress
Type: LoadBalancer
IP: 10.0.153.66
IP: 13.95.67.206
Port: http 8000/TCP
TargetPort: http/TCP
NodePort: http 30933/TCP
Endpoints: 10.244.1.6:8000
Port: https 443/TCP
TargetPort: https/TCP
NodePort: https 32230/TCP
Endpoints: 10.244.1.6:443
Session Affinity: None
External Traffic Policy: Local
HealthCheck NodePort: 32755
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal EnsuringLoadBalancer 4m17s (x43 over 3h10m) service-controller Ensuring load balancer
Warning CreateOrUpdateLoadBalancer 4m16s (x43 over 3h10m) azure-cloud-provider Code="PublicIPAndLBSkuDoNotMatch" Message="Standard sku load balancer /subscriptions/e90bd4d0-3b50-4a27-a7e8-bc88cf5f5398/resourceGroups/mc_identity-k8s-rg_identity-k8s-aks_westeurope/providers/Microsoft.Network/loadBalancers/kubernetes cannot reference Basic sku publicIP /subscriptions/e90bd4d0-3b50-4a27-a7e8-bc88cf5f5398/resourceGroups/MC_identity-k8s-rg_identity-k8s-aks_westeurope/providers/Microsoft.Network/publicIPAddresses/nginx-ingress-pip." Details=[]
kubectl 日志
I1108 12:52:52.862797 7 flags.go:205] Watching for Ingress class: nginx
W1108 12:52:52.863034 7 flags.go:250] SSL certificate chain completion is disabled (--enable-ssl-chain-completion=false)
W1108 12:52:52.863078 7 client_config.go:552] Neither --kubeconfig nor --master was specified. Using the inClusterConfig. This might not work.
I1108 12:52:52.863272 7 main.go:231] Creating API client for https://10.0.0.1:443
-------------------------------------------------------------------------------
NGINX Ingress controller
Release: v0.34.1
Build: v20200715-ingress-nginx-2.11.0-8-gda5fa45e2
Repository: https://github.com/kubernetes/ingress-nginx
nginx version: nginx/1.19.1
-------------------------------------------------------------------------------
I1108 12:52:52.892455 7 main.go:275] Running in Kubernetes cluster version v1.17 (v1.17.13) - git (clean) commit 30d651da517185653e34e7ab99a792be6a3d9495 - platform linux/amd64
I1108 12:52:52.897887 7 main.go:87] Validated default/nginx-ingress-default-backend as the default backend.
I1108 12:52:53.229870 7 main.go:105] SSL fake certificate created /etc/ingress-controller/ssl/default-fake-certificate.pem
W1108 12:52:53.252657 7 store.go:659] Unexpected error reading configuration configmap: configmaps "nginx-ingress-controller" not found
I1108 12:52:53.268067 7 nginx.go:263] Starting NGINX Ingress controller
I1108 12:52:54.468656 7 leaderelection.go:242] attempting to acquire leader lease default/ingress-controller-leader-nginx...
I1108 12:52:54.468691 7 nginx.go:307] Starting NGINX process
W1108 12:52:54.469222 7 controller.go:395] Service "default/nginx-ingress-default-backend" does not have any active Endpoint
I1108 12:52:54.469249 7 controller.go:141] Configuration changes detected, backend reload required.
I1108 12:52:54.473464 7 status.go:86] new leader elected: nginx-ingress-controller-6b45fcd8ff-7mbx4
I1108 12:52:54.543113 7 controller.go:157] Backend successfully reloaded.
I1108 12:52:54.543152 7 controller.go:166] Initial sync, sleeping for 1 second.
W1108 12:52:58.251867 7 controller.go:395] Service "default/nginx-ingress-default-backend" does not have any active Endpoint
I1108 12:53:38.008002 7 leaderelection.go:252] successfully acquired lease default/ingress-controller-leader-nginx
I1108 12:53:38.008203 7 status.go:86] new leader elected: nginx-ingress-controller-6b45fcd8ff-njgjs
帮助我了解我在这里缺少什么?这整个过程就是我试图在公共(public) IP 地址上部署一个简单的 Python 服务。我只是想在公共(public) IP 上公开该服务,无论是 nginx 还是任何其他负载平衡服务,目前使用哪种方法都没有关系。
此外,在我在 Terraform 文件中实现 nginx ingress 之前,当我运行 kubectl get services
时,我可以看到 identity-svc 正在运行,但现在我什至看不到该服务,它只有 nginx ingress Controller 。非常感谢任何帮助。
编辑:如@mynko 所述,将 sku 标准添加到公共(public) IP 创建后,工作流可以成功运行。现在,当我检查以下内容时;
admin@Azure:~$ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
identity-svc LoadBalancer 10.0.188.32 20.56.242.212 8000:30036/TCP 22m
kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 7h28m
nginx-ingress-controller LoadBalancer 10.0.230.164 20.50.221.84 8000:31742/TCP,443:31675/TCP 23m
nginx-ingress-default-backend ClusterIP 10.0.229.217 <none> 8000/TCP 23m
我明白了,我不确定为什么 nginx-ingress-controller
查看端口 80 而不是 8000。此外,当我尝试访问 `20.56.242.212:8000 时,没有加载任何内容。同样在这种情况下,哪个应该是我公开的公共(public) IP?
当我访问 20.50.221.84
时,它显示 default backend - 404
最佳答案
查看 kubernetes 服务警告消息。
Code="PublicIPAndLBSkuDoNotMatch"
您使用的是基本 SKU 公共(public) IP,将其更改为标准。
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/public_ip#sku
关于kubernetes - 如何使用 Terraform 公开具有公共(public) IP 地址的 Azure Kubernetes 集群,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64740298/
有什么方法可以将 Terraform 模板输出用于另一个 Terraform 模板的输入? 例如:我有一个创建 ELB 的 Terraform 模板,我有另一个 Terraform 模板,它将创建一个
我正在使用 Terraform 在 Azure 中设置虚拟网络。 我有几个 VNet,每个 VNet 都有自己的网络安全组 100% 在 Terraform 中管理,在运行 Terraform 之前不
resources and data sources在 terraform 文档中 link ,谁能解释一下它们的区别以及可以使用它们的示例场景 最佳答案 Data Sources :允许 Terra
terraform plan 等命令如何知道/决定使用哪些文件? -help 显示了一个 DIR-OR-PLAN 参数,但没有显示如何使用它: $ terraform -help plan Usage
我在尝试运行使用 terraform lock 的 terraform 脚本时收到以下错误消息。 *Acquiring state lock. This may take a few moments.
我想简化这样的构造 variable "google" { type = object({ project = string region = string
这是一个场景 - 您开发用于研发组织的 terraform 模块。它们已经被一两个微服务使用,转化为十几个 pod。您确定了重构机会,例如将某些功能提取到其自己的 terraform 模块中。很好,但
Terraform 是否支持条件属性?我只想根据变量的值使用属性。 例子: resource "aws_ebs_volume" "my_volume" { availability_zone =
我想将此作为功能请求发布,但我想在发布之前看看是否有其他人找到了一些聪明的方法。或者也许 Hashicorp 的某个人可以告诉我这将是 future 的一个功能 在运行 terraform apply
我在 terraform 的变量插值中遇到了麻烦。这是我的 terraform 配置的样子。即内置函数内的变量 variable "key" {} ssh_keys { pat
运行 terraform 并等待需要很长时间。 所以我想运行它来排除需要最长执行时间的 rds 或者我只想运行 ec2 资源。 有没有办法在 terraform 中做这样的事情? 最佳答案 您可以使用
terraform 是否提供这样的功能来覆盖变量值?假设我已经声明了下面给出的两个变量。 variable "foo" {} variable "bar" { default = "false"} f
我正在为 Terraform Associate Certification 做准备考试。我在 Udemy 上进行了一次练习考试,并收到了一个关于自动安装社区提供程序的问题。但是,根据实际 terra
我有很多使用 Terraform 的 gcp-provider 用 Terraform 0.11 编写的 Terraform 模块,并希望将其升级到 Terraform 0.12。 为此,我需要保留系
我的项目有 2 个存储库。静态网站和服务器。我希望网站由 cloudfront 和 s3 托管,服务器在 elasticbeanstalk 上。我知道这些资源至少需要了解 Route53 资源才能在同
我能有这样的资源吗 resource "foo" "bar.baz"{ ... } 或者以后 . 会把我搞砸吗?特别是,是否允许这样做: resource "foo" "other"{ ...
我能有这样的资源吗 resource "foo" "bar.baz"{ ... } 或者以后 . 会把我搞砸吗?特别是,是否允许这样做: resource "foo" "other"{ ...
运行时terraform init使用 Terraform 时 0.11.3我们收到以下错误: Initializing provider plugins... - Checking for avai
我正在尝试将项目的 CLI 工作区迁移到 Terraform Cloud。我正在使用 Terraform 版本 0.14.8 并遵循官方指南 here . $ terraform0.14.8 work
尝试在Azure Pipeline中将terraform init作为任务运行时,错误指出 spawn C:\hostedtoolcache\windows\terraform\0.12.7\x64\
我是一名优秀的程序员,十分优秀!