Sign inSign up

motomotomato/python-gcloud-k8s-client

By motomotomato

•Updated 9 months ago

Image
0

1.9K

motomotomato/python-gcloud-k8s-client repository overview

⁠python-gcloud-k8s-client

GitHub Docker Hub version status

Google Kubernetes Engine Python client Docker image.

This image is based on the official Python image and contains the Google Cloud SDK and the Kubernetes client.

⁠Usage

$ docker pull motomotomato/python-gcloud-k8s-client

To run Python script, you can use CMD instruction in Dockerfile.

FROM motomotomato/python-gcloud-k8s-client

ENV CLUSTER_NAME=cluster-name
ENV REGION=region
ENV PROJECT_ID=project-id

COPY main.py .
CMD ["main.py"]

By default, this image uses automatically authentication with the Google Cloud SDK. If you want to use a service account, you can override ENTRYPOINT instruction in Dockerfile by entorypoint.sh⁠ script.

entrypoint.sh

#!/bin/bash

gcloud auth activate-service-account --key-file=service-account.json
gcloud container clusters get-credentials ${CLUSTER_NAME} --region ${REGION} --project ${PROJECT_ID}

python $@

By using docker-compose, you can use the service account file and environment variables.

docker-compose.yml

services:
  python-gcloud-k8s-client:
    image: motomotomato/python-gcloud-k8s-client
    volumes:
      - ./service-account.json:/service-account.json
      - ./main.py:/main.py
      - ./entrypoint.sh:/entrypoint.sh
    environment:
      GOOGLE_APPLICATION_CREDENTIALS: /service-account.json
      CLUSTER_NAME: cluster-name
      REGION: region
      PROJECT_ID: project-id
    command: /main.py

⁠Installed packages

⁠Reference

⁠License

MIT License

⁠Author

toms74209200⁠

Tag summary

Content type

Image

Digest

sha256:a1f7d0e3c…

Size

290.6 MB

Last updated

9 months ago

docker pull motomotomato/python-gcloud-k8s-client