Andrew Mercer

Ansible

todo

Containers

Ephemeral container

Create a volume

podman create volume gcloud-config

Pull the container image

podman pull [ hostname ]/[ hostname ]/cloudsdktool/google-cloud-cli:latest

Set an alias

alias 'gcloud=podman run --rm -it --entrypoint gcloud -v gcloud-config:/root/.config/gcloud:Z [ hostname ]/[ hostname ]/cloudsdktool/google-cloud-cli:latest'

Make the alias permanent:

echo "alias 'gcloud=podman run --rm -it --entrypoint gcloud -v gcloud-config:/root/.config/gcloud:Z [ hostname ]/[ hostname ]/cloudsdktool/google-cloud-cli:latest'" >> ~/.bashrc.d/cloud_aliases.sh

Initialize a configuration

gcloud init
gcloud auth login

Run commands

gcloud [ gcloud_command ]
podman volume create gcloud-config
podman run --rm -it -v gcloud-config:/root/.config/gcloud:Z [ hostname ]/google/cloud-sdk:latest [ gcloud_command ]
podman run --rm -it -v gcloud-config:/root/.config/gcloud:Z [ hostname ]/google/cloud-sdk:latest gcloud auth login

Compose file

mkdir -p ~/containers/cloud_computing/gcp/gcloud-sdk
# [ hostname ]

services:
  gcloud:
    image: [ hostname ]/[ hostname ]/cloudsdktool/google-cloud-cli:latest
    container_name: gcloud-sdk
    stdin_open: true
    tty: true
    volumes:
      - gcloud-config:/root/.config/gcloud
    entrypoint: ["gcloud"]
    command: ["--help"]

volumes:
  gcloud-config:
podman-compose run --rm gcloud
podman-compose run --rm gcloud auth login

Install on Fedora desktop

sudo tee -a /etc/[ hostname ].d/[ hostname ] << EOM
[google-cloud-cli]
name=Google Cloud CLI
baseurl=https://[ hostname ]/yum/repos/cloud-sdk-el9-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=0
gpgkey=https://[ hostname ]/yum/doc/[ hostname ]
EOM
[google-cloud-cli]
name=Google Cloud CLI
baseurl=https://[ hostname ]/yum/repos/cloud-sdk-el9-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=0
gpgkey=https://[ hostname ]/yum/doc/[ hostname ]
sudo dnf -y install google-cloud-cli