У меня есть следующий сценарий Terraform для развертывания кластера Kubernestes на AWS .. После развертывания все ресурсы были видны на AWS, включая EKS, но kubernetes_deployment FOR nginx, varni sh, percona не были замечены . Я отлаживал эту проблему, но не могу найти решение.
provider "kubernetes" {
load_config_file = "false"
host = data.aws_eks_cluster.cluster.endpoint
token = data.aws_eks_cluster_auth.cluster.token
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)
}
resource "kubernetes_deployment" "nginx" {
metadata {
name = "scalable-nginx"
labels = {
App = "ScalableNginx"
}
}
spec {
replicas = 4
selector {
match_labels = {
App = "ScalableNginx"
}
}
template {
metadata {
labels = {
App = "ScalableNginx"
}
}
spec {
container {
image = "markoshust/magento-nginx:1.18-2"
name = "magento-nginx"
port {
container_port = 81
}
resources {
limits {
cpu = "0.5"
memory = "512Mi"
}
requests {
cpu = "250m"
memory = "50Mi"
}
}
}
}
}
}
}
resource "kubernetes_service" "nginx" {
metadata {
name = "nginx"
}
spec {
selector = {
App = kubernetes_deployment.nginx.spec.0.template.0.metadata[0].labels.App
}
port {
node_port = 30201
port = 81
target_port = 81
}
type = "NodePort"
}
}
resource "kubernetes_deployment" "magento2-php" {
metadata {
name = "scalable-magento2-php"
labels = {
App = "Scalablemagento2-php"
}
}
spec {
replicas = 4
selector {
match_labels = {
App = "Scalablemagento2-php"
}
}
template {
metadata {
labels = {
App = "Scalablemagento2-php"
}
}
spec {
container {
image = "markoshust/magento-php:7.4-fpm-0"
name = "magento2-php"
port {
container_port = 80
}
resources {
limits {
cpu = "0.5"
memory = "512Mi"
}
requests {
cpu = "250m"
memory = "50Mi"
}
}
}
}
}
}
}
resource "kubernetes_service" "magento2-php" {
metadata {
name = "magento2-php"
}
spec {
selector = {
App = kubernetes_deployment.nginx.spec.0.template.0.metadata[0].labels.App
}
port {
node_port = 30201
port = 80
target_port = 80
}
type = "NodePort"
}
}
resource "kubernetes_deployment" "redis" {
metadata {
name = "scalable-redis"
labels = {
App = "Scalableredis"
}
}
spec {
replicas = 4
selector {
match_labels = {
App = "Scalableredis"
}
}
template {
metadata {
labels = {
App = "Scalableredis"
}
}
spec {
container {
image = "redis"
name = "redis"
port {
container_port = 80
}
resources {
limits {
cpu = "0.5"
memory = "512Mi"
}
requests {
cpu = "250m"
memory = "50Mi"
}
}
}
}
}
}
}
resource "kubernetes_service" "redis" {
metadata {
name = "redis"
}
spec {
selector = {
App = kubernetes_deployment.nginx.spec.0.template.0.metadata[0].labels.App
}
port {
node_port = 30201
port = 80
target_port = 80
}
type = "NodePort"
}
}
resource "kubernetes_deployment" "varnish" {
metadata {
name = "scalable-varnish"
labels = {
App = "Scalablevarnish"
}
}
spec {
replicas = 4
selector {
match_labels = {
App = "Scalablevarnish"
}
}
template {
metadata {
labels = {
App = "Scalablevarnish"
}
}
spec {
container {
image = "varnish"
name = "varnish"
port {
container_port = 80
}
resources {
limits {
cpu = "0.5"
memory = "512Mi"
}
requests {
cpu = "250m"
memory = "50Mi"
}
}
}
}
}
}
}
resource "kubernetes_service" "varnish" {
metadata {
name = "redis"
}
spec {
selector = {
App = kubernetes_deployment.nginx.spec.0.template.0.metadata[0].labels.App
}
port {
node_port = 30201
port = 80
target_port = 80
}
type = "NodePort"
}
}
resource "kubernetes_deployment" "mysqlpercona" {
metadata {
name = "scalable-mysqlpercona"
labels = {
App = "Scalablemysqlpercona"
}
}
spec {
replicas = 4
selector {
match_labels = {
App = "Scalablemysqlperconah"
}
}
template {
metadata {
labels = {
App = "Scalablemysqlpercona"
}
}
spec {
container {
image = "percona"
name = "percona"
port {
container_port = 3306
}
resources {
limits {
cpu = "0.5"
memory = "512Mi"
}
requests {
cpu = "250m"
memory = "50Mi"
}
}
}
}
}
}
}
resource "kubernetes_service" "mysqlpercona" {
metadata {
name = "redis"
}
spec {
selector = {
App = kubernetes_deployment.nginx.spec.0.template.0.metadata[0].labels.App
}
port {
node_port = 30201
port = 3306
target_port = 3306
}
type = "NodePort"
}
}
Скрипты не развертываются, и я могу найти изображение в AWS CLUSTER. Действительно нужна помощь сообщества в решении проблемы. Спасибо.