• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

gcp

GCP Extend ext4 Boot Volume

July 28, 2022

Here’s how to extend an ext4 boot volume.

gcloud compute disks resize DISK_NAME --size DISK_SIZE --zone ZONE --project PROJECTID

gcloud compute disks resize DISK_NAME --size DISK_SIZE --zone ZONE --project PROJECTID

Resize the file system. Example / is on sda3.

growpart /dev/sda 3
resize2fs /dev/sda3

growpart /dev/sda 3 resize2fs /dev/sda3

Filed Under: Cloud, Linux Tagged With: boot, ext4, extend, gcloud, gcp, growpart, resize2fs, volume

GCP Create Service Account via Terraform

June 27, 2022

How to create service account in GCP via Terraform.

provider "google" {
  project = "your_project_id"
}
resource "google_service_account" "service_account" {
  account_id   = "your-service-account-name"
  display_name = "test service account built by terraform"
}

provider "google" { project = "your_project_id" } resource "google_service_account" "service_account" { account_id = "your-service-account-name" display_name = "test service account built by terraform" }

Filed Under: Cloud Tagged With: create, gcp, service account, terraform

GCP CloudShell via Terminal

June 20, 2022

Connect to your CloudShell environment from your terminal.

$ gcloud cloud-shell ssh
Welcome to Cloud Shell! Type "help" to get started.
first.last@cloudshell $
first.last@cloudshell $

$ gcloud cloud-shell ssh Welcome to Cloud Shell! Type "help" to get started. first.last@cloudshell $ first.last@cloudshell $

Once logged in, you can set your project.

first.last@cloudshell $ gcloud config set project $PROJECT_ID

first.last@cloudshell $ gcloud config set project $PROJECT_ID

Filed Under: Cloud Tagged With: cloud shell, connect, gcp, terminal

GCP Move VM to another VPC

June 19, 2022

Here’s how to move a VM to another VPC.

Stop VM.

gcloud compute instances stop $INSTANCE_NAME \
--zone $ZONE_NAME \
--project $PROJECT_ID

gcloud compute instances stop $INSTANCE_NAME \ --zone $ZONE_NAME \ --project $PROJECT_ID

Move VM to another VPC.

gcloud compute instances network-interfaces update $INSTANCE_NAME \
--zone $ZONE_NAME \
--network-interface=nic0 \
--network $YOUR_NETWORK \
--subnetwork $YOUR_SUBNETWORK \
--project $PROJECT_ID

gcloud compute instances network-interfaces update $INSTANCE_NAME \ --zone $ZONE_NAME \ --network-interface=nic0 \ --network $YOUR_NETWORK \ --subnetwork $YOUR_SUBNETWORK \ --project $PROJECT_ID

Start VM.

gcloud compute instances start $INSTANCE_NAME \
--zone $ZONE_NAME \
--project $PROJECT_ID

gcloud compute instances start $INSTANCE_NAME \ --zone $ZONE_NAME \ --project $PROJECT_ID

Filed Under: Cloud Tagged With: gcp, move, vm, vpc

gsutil Describe Bucket

June 13, 2022

How to describe a GCP bucket.

gsutil ls -L -b gs://my-bucket

gsutil ls -L -b gs://my-bucket

Filed Under: Cloud Tagged With: bucket, describe, gcp, gsutil

GCP Find Instance Boot Disk

April 13, 2022

How to find a boot disk from an instance.

gcloud compute instances describe servername \
--format='get(disks[0].source)' \
--zone=us-central1-c \
--project project-id

gcloud compute instances describe servername \ --format='get(disks[0].source)' \ --zone=us-central1-c \ --project project-id

Result

https://www.googleapis.com/compute/v1/projects/project-id/zones/us-central1-f/disks/servername-boot

https://www.googleapis.com/compute/v1/projects/project-id/zones/us-central1-f/disks/servername-boot

Filed Under: Cloud Tagged With: boot, disk, find, gcp

GCP Backup Instance

April 3, 2022

Here’s the script to backup GCP disks.

#!/bin/bash
now=$(date +%s)
disks=$(gcloud compute disks list --project project-id --filter="users:instance" --format="value(name)")
for disk in $disks
do
  gcloud compute disks snapshot $disk \
  --snapshot-names=$disk-$now \
  --zone=us-central1-a \
  --project=project-id \
  --async
done

#!/bin/bash now=$(date +%s) disks=$(gcloud compute disks list --project project-id --filter="users:instance" --format="value(name)") for disk in $disks do gcloud compute disks snapshot $disk \ --snapshot-names=$disk-$now \ --zone=us-central1-a \ --project=project-id \ --async done

Filed Under: Cloud, Linux Tagged With: backup, disks, gcp, manual, snapshots

GCP Project Quotas

March 8, 2022

Here’s how to get your project quotas in GCP.

gcloud compute project-info describe --project your-project-id

gcloud compute project-info describe --project your-project-id

Filed Under: Cloud Tagged With: gcloud, gcp, project, quotas

  • « Go to Previous Page
  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Go to page 4
  • Interim pages omitted …
  • Go to page 16
  • Go to Next Page »
  • Home
  • About
  • Archives

Copyright © 2023