0

我正在关注 Safari 上的 Cloud Foundry BOSH Fundamentals LiveLessons。我已将 BOSH via 部署bbl到 GCP 中。我正在使用一个免费试用帐户,它为我提供了 8 个 vCPU。到目前为止,我使用了两种:一种用于 Director,一种用于 jumpbox。

我正在尝试使用以下命令部署 nginx:

bosh deploy -d nginx nginx.yml

nginx.yml 在哪里

---
name: nginx

releases:
- name: nginx
  version: latest

stemcells:
- alias: ubuntu
  os: ubuntu-trusty
  version: latest

instance_groups:
- name: nginx
  azs: [z2]
  instances: 1
  vm_type: sharedcpu
  stemcell: ubuntu
  networks:
  - name: default
  jobs:
  - name: nginx
    release: nginx
    properties:
      nginx_conf: |
        worker_processes  1;
        er ror_log /var/vcap/sys/log/nginx/error.log   info;
        #pid        logs/nginx.pid; # PIDFILE is configured via monit's ctl
        events {
          worker_connections  1024;
        }
        http {
          include /var/vcap/packages/nginx/conf/mime.types;
          default_type  application/octet-stream;
          sendfile        on;
          ssi on;
          keepalive_timeout  65;
          server_names_hash_bucket_size 64;
          server {
            server_name _; # invalid value which will never trigger on a real hostname.
            listen 0.0.0.0:80;
            access_log /var/vcap/sys/log/nginx/toto-access.log;
            error_log /var/vcap/sys/log/nginx/toto-error.log;
          }
          root /var/vcap/store/nginx;
          index index.shtml index.html index.htm;
        }
      pre_start: |
        #!/bin/bash -ex
        NGINX_DIR=/var/vcap/store/nginx
        if [ ! -d $NGINX_DIR ]; then
          mkdir -p $NGINX_DIR
          cd $NGINX_DIR
          echo  '<html><title>hello</title><body><h1>Hello <!--#echo var="REMOTE_ADDR" --></h1></body></html>' > index.shtml
        fi

update:
  canaries: 1
  max_in_flight: 1
  serial: false
  canary_watch_time: 1000-60000
  update_watch_time: 1000-60000

这给了我以下错误:

Task 8

Task 8 | 15:47:32 | Preparing deployment: Preparing deployment (00:00:01)
Task 8 | 15:47:33 | Preparing package compilation: Finding packages to compile (00:00:00)
Task 8 | 15:47:33 | Compiling packages: nginx/d6ddf5c4782669341b260a27c53208d32a17b3a5 (00:00:10)
                   L Error: CPI error 'Bosh::Clouds::VMCreationFailed' with message 'VM failed to create: googleapi: Error 403: Quota 'CPUS' exceeded. Limit: 8.0 in region europe-west3., quotaExceeded' in 'create_vm' CPI method
Task 8 | 15:47:43 | Error: CPI error 'Bosh::Clouds::VMCreationFailed' with message 'VM failed to create: googleapi: Error 403: Quota 'CPUS' exceeded. Limit: 8.0 in region europe-west3., quotaExceeded' in 'create_vm' CPI method

鉴于我应该剩下 6 个 vCPU,我尝试通过 Web 控制台手动创建实例,看看是否会收到类似的错误。我没有,我能够使用剩余的 6 个 vCPU 创建实例。知道发生了什么吗?

4

1 回答 1

0

默认情况下,部署环境中的编译 VM占用bbl8 个 CPU,这会很快耗尽您的配额。编译 VM 的大小由 BOSH 云配置设置。

解决此问题的步骤取决于您的bbl. 此修复假定您使用的是bbl5 或更高版本。

将具有以下内容的文件写入cloud-config您的bbl状态目录的目录:

- type: replace
  path: /compilation/vm_type
  value: n1-highcpu-2
- type: replace
  path: /compilation/workers
  value: 1

(只要不覆盖现有文件,您可以随意调用此文件。我将其命名为compilation-vms.yml.)

然后bbl up再次运行。

下次您的 BOSH 控制器尝试创建编译 VM 时,它将默认为单个 2-CPU VM。

于 2018-09-08T16:59:12.400 回答