简体   繁体   English

如何使用自定义图像在 Ansible 中创建 Google Kubernetes (GKE) 集群?

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

I've used this pattern in the past to create a GKE and it's worked great, but now I need to define a custom image type to use.我过去曾使用这种模式来创建 GKE,效果很好,但现在我需要定义一个自定义图像类型来使用。

Here's the ansible playbook i'm working with.这是我正在使用的 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

I'm trying to use an E2 based image with 16 cores and 70GB of RAM.我正在尝试使用具有 16 个内核和 70GB RAM 的基于 E2 的映像。 The spec don't matter as much as the fact that I can't specify a 'machine type' that's already preconfigured.规范并不重要,因为我无法指定已经预配置的“机器类型”。

Is it possible to still use ansible to create the cluster?是否仍然可以使用 ansible 创建集群? Do I need to create a custom image type to reference?我是否需要创建自定义图像类型以供参考?

Just to clarify, there are no errors being thrown out.只是为了澄清,没有错误被抛出。 defining the machine_type as e2-medium doesn't allow me to allocate the resources I need and define an instance with the resources required.将 machine_type 定义为 e2-medium 不允许我分配所需的资源并定义具有所需资源的实例。 I'm asking how to say use e2-medium as a base and increase the ram allocation to 70GB or if that is feasible?我在问如何说使用 e2-medium 作为基础并将 ram 分配增加到 70GB,或者这是否可行?

IIUC, you should be able to reference your machine type as e2-custom-16-71680 IIUC,您应该能够将您的机器类型引用为e2-custom-16-71680

ie: IE:

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

The (hidden) documentation for specifying custom machine types:用于指定自定义机器类型的(隐藏)文档:

https://cloud.google.com/compute/docs/instances/creating-instance-with-custom-machine-type#gcloud 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