google-api-python-client icon indicating copy to clipboard operation
google-api-python-client copied to clipboard

Kubernetes Engine API does not allow for CUSTOM imageTypes

Open kajiya3141 opened this issue 3 years ago • 0 comments

Hey all! I've been trying to launch a cluster using a CUSTOM imageType ...

Environment details

  • OS type and version: Ubuntu 22.04.1 LTS
  • Python version: 3.10.6
  • pip version: pip 22.3
  • google-api-python-client version: 2.61.0

Code example

from googleapiclient import discovery
from oauth2client.client import GoogleCredentials
creds = GoogleCredentials.get_application_default()
service = discovery.build('container', 'v1beta1', credentials=creds)
project_id = 'my-private-project'
location = 'us-central1-f'
parent = 'projects/' + project_id + '/locations/' + location
body = {
  "parent": parent,
  "projectId": project_id,
  "zone": location,
  "cluster": {
    "name": "api-custom-node",
    "nodeConfig": {
      "accelerators": [
        {
          "acceleratorCount": 1,
          "acceleratorType": "nvidia-tesla-v100"
        }
      ],
      "imageType": "CUSTOM",
      "gvnic": {
        "enabled": True
      },
      "machineType": "n1-standard-2"
    },
    "initialNodeCount": 1
  }
}
request = service.projects().locations().clusters().create(parent=parent, body=body)
response = request.execute()

Stack trace/error

googleapiclient.errors.HttpError: <HttpError 400 when requesting https://container.googleapis.com/v1beta1/projects/xxxx/locations/us-central1-f/clusters?alt=json returned "NodeConfig.CustomImageConfig.ImageProject must be specified when using custom images.  Your project may not be authorized to use custom images.". Details: "NodeConfig.CustomImageConfig.ImageProject must be specified when using custom images.  Your project may not be authorized to use custom images.">

Rationale

(Please disregard "Your project may not be authorized to use custom images" here; I can launch custom clusters using gcloud so I'm positive it's not a permissions error.)

I just assumed I was using a bad JSON payload, so I went over to the API Explorer in GCE. I've tried adding CustomImageConfig.ImageProject (and other variations) to nodeConfig with no luck - just lots of 400 errors. I also can't find anything in the documention about CustomImageConfig or the like.

So I guess my question is - is it possible to launch CUSTOM imageType clusters using the API?

Thanks in advance :)

kajiya3141 avatar Oct 20 '22 12:10 kajiya3141