2

在将我的集群节点映像从CONTAINER_VM升级到CONTAINER_OPTIMIZED_OS后,我遇到了PHP 应用程序性能下降多达 10 次的问题。我是否错过了配置中的某些内容或常见问题?我尝试使用具有更多 CPU 和内存的机器,但它略微影响了性能。

地形配置:

resource "google_compute_address" "dev-cluster-address" {
  name   = "dev-cluster-address"
  region = "europe-west1"
}

resource "google_container_cluster" "dev-cluster" {
  name               = "dev-cluster"
  zone               = "europe-west1-d"
  initial_node_count = 2
  node_version       = "1.7.5"

  master_auth {
    username = "*********-dev"
    password = "*********"
  }

  node_config {
    oauth_scopes = [
      "https://www.googleapis.com/auth/monitoring",
      "https://www.googleapis.com/auth/logging.write",
      "https://www.googleapis.com/auth/servicecontrol",
      "https://www.googleapis.com/auth/service.management.readonly",
      "https://www.googleapis.com/auth/devstorage.full_control",
      "https://www.googleapis.com/auth/sqlservice.admin"
    ]
    machine_type = "n1-standard-1"
    disk_size_gb = 20
    image_type = "COS"
  }
}

Symfony 应用程序的 Kubernetes 部署:

apiVersion: apps/v1beta1
kind: Deployment
metadata:
    name: deployment-dev
spec:
    replicas: 2
    strategy:
        type: RollingUpdate
        rollingUpdate:
            maxSurge: 1
            maxUnavailable: 1
    template:
        metadata:
            labels:
                app: dev
        spec:
            containers:
                - name: nginx
                  image: nginx:1.13.5-alpine
                  volumeMounts:
                      - name: application
                        mountPath: /var/www/web
                      - name: nginx-config
                        mountPath: /etc/nginx/conf.d
                  ports:
                      - containerPort: 80
                  resources:
                      limits:
                          cpu: "20m"
                          memory: "64M"
                      requests:
                          cpu: "5m"
                          memory: "16M"
                - name: php
                  image: ********
                  lifecycle:
                      postStart:
                          exec:
                              command:
                                  - "bash"
                                  - "/var/www/provision/files/init_php.sh"
                  envFrom:
                      - configMapRef:
                          name: symfony-config-dev
                  volumeMounts:
                      - name: application
                        mountPath: /application
                      - name: logs
                        mountPath: /var/www/var/logs
                      - name: lexik-jwt-keys
                        mountPath: /var/www/var/jwt
                  ports:
                      - containerPort: 9000
                  resources:
                      limits:
                          cpu: "400m"
                          memory: "1536M"
                      requests:
                          cpu: "300m"
                          memory: "1024M"
                - name: cloudsql-proxy-mysql
                  image: gcr.io/cloudsql-docker/gce-proxy:1.09
                  resources:
                      limits:
                          cpu: "10m"
                          memory: "64M"
                      requests:
                          cpu: "5m"
                          memory: "16M"
                  command:
                      - "/cloud_sql_proxy"
                      - "-instances=***:europe-west1:dev1=tcp:0.0.0.0:3306"
                - name: cloudsql-proxy-analytics
                  image: gcr.io/cloudsql-docker/gce-proxy:1.09
                  resources:
                      limits:
                          cpu: "20m"
                          memory: "64M"
                      requests:
                          cpu: "10m"
                          memory: "16M"
                  command:
                      - "/cloud_sql_proxy"
                      - "-instances=***:europe-west1:analytics-dev1=tcp:0.0.0.0:3307"
                - name: sidecar-logging
                  image: alpine:3.6
                  args: [/bin/sh, -c, 'tail -n+1 -f /var/www/var/logs/prod.log']
                  volumeMounts:
                      - name: logs
                        mountPath: /var/www/var/logs
                  resources:
                      limits:
                          cpu: "5m"
                          memory: "20M"
                      requests:
                          cpu: "5m"
                          memory: "20M"
            volumes:
                - name: application
                  emptyDir: {}
                - name: logs
                  emptyDir: {}
                - name: nginx-config
                  configMap:
                      name: config-dev
                      items:
                          - key: nginx
                            path: default.conf
                - name: lexik-jwt-keys
                  configMap:
                      name: config-dev
                      items:
                          - key: lexik_jwt_private_key
                            path: private.pem
                          - key: lexik_jwt_public_key
                            path: public.pem
4

1 回答 1

1

原因之一可能是 Kubernetes 实际上开始使用 Container-Optimized OS 强制执行 CPU 限制。

resources:
    limits:
        cpu: "20m"

这些并未在较旧的 ContainerVM 映像上强制执行。

您能否尝试从您的 pod-spec 中删除/放松 cpu 限制,看看是否有帮助?

于 2017-09-19T18:23:17.120 回答