容器优化的操作系统性能

时间:2017-09-18 10:03:48

标签: kubernetes google-kubernetes-engine google-container-os

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

Terraform配置:

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 Application 的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

1 个答案:

答案 0 :(得分:1)

其中一个原因可能是Kubernetes实际上开始使用容器优化操作系统强制执行CPU限制。

resources:
    limits:
        cpu: "20m"

这些未在旧版ContainerVM图像上强制执行。

您可以尝试从pod规范中删除/放宽cpu限制,看看它是否有帮助?