簡體   English   中英

如何使用自定義圖像在 Ansible 中創建 Google Kubernetes (GKE) 集群?

[英]How to create Google Kubernetes (GKE) cluster in Ansible with custom image?

我過去曾使用這種模式來創建 GKE,效果很好,但現在我需要定義一個自定義圖像類型來使用。

這是我正在使用的 ansible 劇本。

- name: GCE
  hosts: localhost
  gather_facts: no
  vars_files:
    - vars/default.yml

  tasks:
    - name: create cluster
      gcp_container_cluster:
        name: "{{ cluster_name }}"
        initial_node_count: "{{ node_count}}"
        initial_cluster_version: "{{ cluster_kubernetes_version }}"
        master_auth:
          username: admin
          password: "{{ cloud_admin }}"
        node_config:
          machine_type:  e2-medium
          disk_size_gb: "{{ disk_size_gb }}"
        location: "{{ cluster_zone}}"
        project: "{{ project }}"
        auth_kind: "{{ auth_kind }}"
        service_account_file: "{{ service_account_file }}"
        state: present
        scopes: "{{ scopes }}"
      register: cluster
    - name: create a node pool
      google.cloud.gcp_container_node_pool:
        name: default-pool
        autoscaling:
          enabled: yes
          min_node_count: "{{ node_count}}"
          max_node_count: "{{ max_node_count }}"
        initial_node_count: "{{ node_count }}"
        cluster: "{{ cluster }}"
        location: "{{ cluster_zone}}"
        config:
          machine_type: e2-medium
          disk_size_gb: "{{ disk_size_gb }}"
        project: "{{ gce_project}}"
        auth_kind: serviceaccount
        service_account_file: "{{ service_account_file }}"
        state: presen

我正在嘗試使用具有 16 個內核和 70GB RAM 的基於 E2 的映像。 規范並不重要,因為我無法指定已經預配置的“機器類型”。

是否仍然可以使用 ansible 創建集群? 我是否需要創建自定義圖像類型以供參考?

只是為了澄清,沒有錯誤被拋出。 將 machine_type 定義為 e2-medium 不允許我分配所需的資源並定義具有所需資源的實例。 我在問如何說使用 e2-medium 作為基礎並將 ram 分配增加到 70GB,或者這是否可行?

IIUC,您應該能夠將您的機器類型引用為e2-custom-16-71680

IE:

- name: your-cluster
  google.cloud.gcp_container_cluster:
    ...
    node_config:
      machine_type: e2-custom-16-71680
      disk_size_gb: "{{ disk_size_gb }}"
    ...

用於指定自定義機器類型的(隱藏)文檔:

https://cloud.google.com/compute/docs/instances/creating-instance-with-custom-machine-type#gcloud

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM