• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

Archives for September 2020

GCP Create Internal IP Reservation

September 29, 2020

Here’s how to create an internal IP reservation in GCP.

gcloud compute addresses create my-private-ip-reservation \
--addresses 10.128.0.15 \
--region us-central1 \
--subnet default \
--project project-id

gcloud compute addresses create my-private-ip-reservation \ --addresses 10.128.0.15 \ --region us-central1 \ --subnet default \ --project project-id

To list your reserved IPs.

gcloud compute addresses list \
--project project-id

gcloud compute addresses list \ --project project-id

Filed Under: Cloud Tagged With: addresses, compute, create, gcloud, gcp, ip address, list, reserve

Logitech K811 Page Up and Down

September 23, 2020

I’ve been using this keyboard for a few years, but never knew how to use page and page down. It’s …

fn + up arrow = page up
fn + down arrow = page down

fn + up arrow = page up fn + down arrow = page down

Filed Under: Misc Tagged With: down, fn, function, k811, logitech, page, up

GCP List Instances with Service Account

September 23, 2020

Here’s how to list GCP instances with a specific service account.

gcloud compute instances list \
--project your-project-id \
--format="value(name,serviceAccounts[].email)" \
--filter="serviceAccounts.email=your-service-account@email.com AND name~\bwp"

gcloud compute instances list \ --project your-project-id \ --format="value(name,serviceAccounts[].email)" \ --filter="serviceAccounts.email=your-service-account@email.com AND name~\bwp"

I’m using filters to look for a specific service account, and any instance starting with ‘wp.’ \b means begins with.

Filed Under: Cloud Tagged With: gcp, instances, list, serviceaccount

GCP Listing Reservations

September 21, 2020

Here’s how to list reservations in GCP.

gcloud compute reservations list --project project-id

gcloud compute reservations list --project project-id

Specify a zone.

gcloud compute reservations list \
--filter="zone:('us-central1-a')" \
--project project-id

gcloud compute reservations list \ --filter="zone:('us-central1-a')" \ --project project-id

Filed Under: Cloud Tagged With: filter, gcp, list, project, reservations, zone

Dos2unix

September 18, 2020

In Windows a new line, is a CR (carriage return) followed by LF (line feed). In Linux, it’s just LF. If you bring over a text file from Windows to Linux, sometimes you’ll end up with a file with a bunch of ^M at the end of each line, which will breaks a lot of things. To fix, just run dos2unix.

dos2unix file.txt

dos2unix file.txt

Filed Under: Linux Tagged With: carriage return, convert, cr, dos2unix, lf, line feed

GCP Identify Your Disks

September 16, 2020

Here’s how to identify your disks on the system to cross check with GCP Dashboard.

ls -l /dev/disk/by-id

ls -l /dev/disk/by-id

Result:

[root@servername ~]# ls -l /dev/disk/by-id
total 0
lrwxrwxrwx. 1 root root  9 Sep 15 05:30 google-boot -> ../../sda
lrwxrwxrwx. 1 root root 10 Sep 15 05:30 google-boot-part1 -> ../../sda1
lrwxrwxrwx. 1 root root  9 Sep 15 05:30 google-persistent-disk-1 -> ../../sdb
lrwxrwxrwx. 1 root root  9 Sep 15 05:30 scsi-0Google_PersistentDisk_boot -> ../../sda
lrwxrwxrwx. 1 root root 10 Sep 15 05:30 scsi-0Google_PersistentDisk_boot-part1 -> ../../sda1
lrwxrwxrwx. 1 root root  9 Sep 15 05:30 scsi-0Google_PersistentDisk_persistent-disk-1 -> ../../sdb

[root@servername ~]# ls -l /dev/disk/by-id total 0 lrwxrwxrwx. 1 root root 9 Sep 15 05:30 google-boot -> ../../sda lrwxrwxrwx. 1 root root 10 Sep 15 05:30 google-boot-part1 -> ../../sda1 lrwxrwxrwx. 1 root root 9 Sep 15 05:30 google-persistent-disk-1 -> ../../sdb lrwxrwxrwx. 1 root root 9 Sep 15 05:30 scsi-0Google_PersistentDisk_boot -> ../../sda lrwxrwxrwx. 1 root root 10 Sep 15 05:30 scsi-0Google_PersistentDisk_boot-part1 -> ../../sda1 lrwxrwxrwx. 1 root root 9 Sep 15 05:30 scsi-0Google_PersistentDisk_persistent-disk-1 -> ../../sdb

Filed Under: Cloud Tagged With: device, disks, gcp, identify, name, volume

GCP Disks Attach To An Instance

September 15, 2020

Here’s how to display a list the disks attached to an instance.

gcloud compute instances describe instance-name \
--project project-id \
--zone us-central1-c \
--format='yaml(disks[].source)'

gcloud compute instances describe instance-name \ --project project-id \ --zone us-central1-c \ --format='yaml(disks[].source)'

Filed Under: Cloud Tagged With: compute, describe, disks, gcp, instances, list, yaml

GCP Create Instance With Reservations

September 14, 2020

Here’s how to create an instance with CUD (committed used discounts) reservations.

gcloud compute instances create instance-name \
--no-address \
--private-network-ip 10.0.0.24 \
--source-machine-image=projects/project-id/global/machineImages/image-name \
--subnet=https://www.googleapis.com/compute/v1/projects/your-project/regions/us-central1/subnetworks/your-sub-network \
--machine-type=n1-standard-4 \
--reservation-affinity=specific \
--reservation=your-reservation-name \
--zone=us-central1-a \
--project=your-project-id

gcloud compute instances create instance-name \ --no-address \ --private-network-ip 10.0.0.24 \ --source-machine-image=projects/project-id/global/machineImages/image-name \ --subnet=https://www.googleapis.com/compute/v1/projects/your-project/regions/us-central1/subnetworks/your-sub-network \ --machine-type=n1-standard-4 \ --reservation-affinity=specific \ --reservation=your-reservation-name \ --zone=us-central1-a \ --project=your-project-id

Filed Under: Cloud Tagged With: compute, cud, gcp, reservations

  • Go to page 1
  • Go to page 2
  • Go to Next Page »
  • Home
  • About
  • Archives

Copyright © 2023