Showing posts with label Qwik-Start. Show all posts
Showing posts with label Qwik-Start. Show all posts

Container-Optimized OS: Qwik Start

Container-Optimized OS is an operating system image for your Compute Engine VMs that is optimized for running Docker containers, and is Google's recommended OS for running containers on Google Cloud. In this lab you will create a Container-Optimized instance using the Cloud Console and the CLI.

Since it comes with all container-related dependencies preinstalled, Container-Optimized OS allows your cluster to quickly scale up or down in response to traffic or workload changes, optimizing your spend and improving your reliability.

Container-Optimized OS powers many Google Cloud services such as Kubernetes Engine and Cloud SQL, making it Google's go-to solution for container workloads.



Container-Optimized OS benefits

Run Containers Out of the Box: Container-Optimized OS instances come pre-installed with the Docker runtime and cloud-init. With a Container-Optimized OS instance, you can bring up your Docker container at the same time you create your VM, with no on-host setup required.

Smaller attack surface: Container-Optimized OS has a smaller footprint, reducing your instance's potential attack surface.

Locked-down by default: Container-Optimized OS instances include a locked-down firewall and other security settings by default.

Automatic Updates: Container-Optimized OS instances are configured to automatically download weekly updates in the background; only a reboot is necessary to use the latest updates.

Use cases for Container-Optimized OS

Container-Optimized OS can be used to run most Docker containers. You should consider using Container-Optimized OS as the operating system for your Compute Engine instance if you have the following needs:

You need support for Docker containers or Kubernetes with minimal setup.

You need an operating system that has a small footprint and is security hardened for containers.

You need an operating system that is tested and verified for running Kubernetes on your Compute Engine instances.
Task 1. Create an instance using the console (this is without "nginx" image)
To run a Compute Engine instance with the Container-Optimized OS and a Docker container of your choice.

Container-Optimized OS features
Compute Engine provides several public VM images that you can use to create instances and run your container workloads. Some of these public VM images have a minimalistic container-optimized operating system that includes newer versions of Docker, rkt, or Kubernetes preinstalled. The following public image families are designed specifically to run containers:

Container-Optimized OS from Google
Includes: Docker, Kubernetes
Image project: cos-cloud
Image family: cos-stable
CoreOS
Includes: Docker, rkt, Kubernetes
Image project: coreos-cloud
Image family: coreos-stable
Ubuntu
Includes: LXD
Image project: ubuntu-os-cloud
Image family: ubuntu-1604-lts
Windows
Includes: Docker
Image project: windows-cloud
Image family: windows-1709-core-for-containers
In a production environment, if you need to run specific container tools and technologies on images that do not include them by default, install those technologies manually.







GCLOUD CLI:

gcloud compute instances create containerized-vm --project=qwiklabs-gcp-00-e5d2c85a4053 --zone=us-central1-a --machine-type=n1-standard-1 --network-interface=network-tier=PREMIUM,stack-type=IPV4_ONLY,subnet=default --metadata=enable-oslogin=true --maintenance-policy=MIGRATE --provisioning-model=STANDARD --service-account=1052499391487-compute@developer.gserviceaccount.com --scopes=https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/trace.append --tags=http-server --create-disk=auto-delete=yes,boot=yes,device-name=containerized-vm,image=projects/cos-cloud/global/images/cos-101-17162-279-1,mode=rw,size=10,type=projects/qwiklabs-gcp-00-e5d2c85a4053/zones/us-central1-a/diskTypes/pd-balanced --no-shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring --labels=goog-ec-src=vm_add-gcloud --reservation-affinity=any




TERRAFORM CODE:

# This code is compatible with Terraform 4.25.0 and versions that are backwards compatible to 4.25.0.
# For information about validating this Terraform code, see https://developer.hashicorp.com/terraform/tutorials/gcp-get-started/google-cloud-platform-build#format-and-validate-the-configuration

resource "google_compute_instance" "containerized-vm" {
  boot_disk {
    auto_delete = true
    device_name = "containerized-vm"

    initialize_params {
      image = "projects/cos-cloud/global/images/cos-101-17162-279-1"
      size  = 10
      type  = "pd-balanced"
    }

    mode = "READ_WRITE"
  }

  can_ip_forward      = false
  deletion_protection = false
  enable_display      = false

  labels = {
    goog-ec-src = "vm_add-tf"
  }

  machine_type = "n1-standard-1"

  metadata = {
    enable-oslogin = "true"
  }

  name = "containerized-vm"

  network_interface {
    access_config {
      network_tier = "PREMIUM"
    }

    subnetwork = "projects/qwiklabs-gcp-00-e5d2c85a4053/regions/us-central1/subnetworks/default"
  }

  scheduling {
    automatic_restart   = true
    on_host_maintenance = "MIGRATE"
    preemptible         = false
    provisioning_model  = "STANDARD"
  }

  service_account {
    email  = "1052499391487-compute@developer.gserviceaccount.com"
    scopes = ["https://www.googleapis.com/auth/devstorage.read_only", "https://www.googleapis.com/auth/logging.write", "https://www.googleapis.com/auth/monitoring.write", "https://www.googleapis.com/auth/service.management.readonly", "https://www.googleapis.com/auth/servicecontrol", "https://www.googleapis.com/auth/trace.append"]
  }

  shielded_instance_config {
    enable_integrity_monitoring = true
    enable_secure_boot          = false
    enable_vtpm                 = true
  }

  tags = ["http-server"]
  zone = "us-central1-a"
}

labs-gcp-00-e5d2c85a4053)$ 
student_04_1583bf2c38bf@cloudshell:~ (qwiklabs-gcp-00-e5d2c85a4053)$ 
student_04_1583bf2c38bf@cloudshell:~ (qwiklabs-gcp-00-e5d2c85a4053)$ gcloud compute images list --project cos-cloud --no-standard-images

NAME: cos-101-17162-279-1
PROJECT: cos-cloud
FAMILY: cos-101-lts
DEPRECATED: 
STATUS: READY

NAME: cos-105-17412-156-5
PROJECT: cos-cloud
FAMILY: cos-105-lts
DEPRECATED: 
STATUS: READY

NAME: cos-93-16623-402-50
PROJECT: cos-cloud
FAMILY: cos-93-lts
DEPRECATED: 
STATUS: READY

NAME: cos-97-16919-353-4
PROJECT: cos-cloud
FAMILY: cos-97-lts
DEPRECATED: 
STATUS: READY

NAME: cos-arm64-101-17162-279-1
PROJECT: cos-cloud
FAMILY: cos-arm64-101-lts
DEPRECATED: 
STATUS: READY

NAME: cos-arm64-105-17412-156-5
PROJECT: cos-cloud
FAMILY: cos-arm64-105-lts
DEPRECATED: 
STATUS: READY

NAME: cos-arm64-beta-105-17412-156-5
PROJECT: cos-cloud
FAMILY: cos-arm64-beta
DEPRECATED: 
STATUS: READY

NAME: cos-arm64-dev-109-17788-0-0
PROJECT: cos-cloud
FAMILY: cos-arm64-dev
DEPRECATED: 
STATUS: READY

NAME: cos-arm64-stable-105-17412-156-5
PROJECT: cos-cloud
FAMILY: cos-arm64-stable
DEPRECATED: 
STATUS: READY

NAME: cos-beta-105-17412-156-5
PROJECT: cos-cloud
FAMILY: cos-beta
DEPRECATED: 
STATUS: READY

NAME: cos-dev-109-17788-0-0
PROJECT: cos-cloud
FAMILY: cos-dev
DEPRECATED: 
STATUS: READY

NAME: cos-stable-105-17412-156-5
PROJECT: cos-cloud
FAMILY: cos-stable
DEPRECATED: 
STATUS: READY
student_04_1583bf2c38bf@cloudshell:~ (qwiklabs-gcp-00-e5d2c85a4053)$ 
student_04_1583bf2c38bf@cloudshell:~ (qwiklabs-gcp-00-e5d2c85a4053)$ gcloud compute images list --project cos-cloud --no-standard-images | grep cos-stable
NAME: cos-stable-105-17412-156-5
FAMILY: cos-stable
student_04_1583bf2c38bf@cloudshell:~ (qwiklabs-gcp-00-e5d2c85a4053)$ 
student_04_1583bf2c38bf@cloudshell:~ (qwiklabs-gcp-00-e5d2c85a4053)$  gcloud beta compute instances create-with-container containerized-vm2 \
     --image cos-stable-72-11316-136-0 \
     --image-project cos-cloud \
     --container-image nginx \
     --container-restart-policy always \
     --zone us-central1-a \
     --machine-type n1-standard-1
Created [https://www.googleapis.com/compute/beta/projects/qwiklabs-gcp-00-e5d2c85a4053/zones/us-central1-a/instances/containerized-vm2].
WARNING: Some requests generated warnings:
 - The resource 'projects/cos-cloud/global/images/cos-stable-72-11316-136-0' is deprecated. A suggested replacement is 'projects/cos-cloud/global/images/cos-stable-72-11316-171-0'.

NAME: containerized-vm2
ZONE: us-central1-a
student_04_1583bf2c38bf@cloudshell:~ (qwiklabs-gcp-00-e5d2c85a4053)$ 
student_04_1583bf2c38bf@cloudshell:~ (qwiklabs-gcp-00-e5d2c85a4053)$


student_04_1583bf2c38bf@cloudshell:~ (qwiklabs-gcp-00-e5d2c85a4053)$ history
    1  gcloud compute images list --project cos-cloud --no-standard-images
    2  gcloud compute images list --project cos-cloud --no-standard-images | grep cos-stable
    3  gcloud compute firewall-rules create allow-containerized-internal  --allow tcp:80   --source-ranges 0.0.0.0/0   --network default
    4  history
student_04_1583bf2c38bf@cloudshell:~ (qwiklabs-gcp-00-e5d2c85a4053)$ 

Cloud Source Repositories: Qwik Start

 Google Cloud Source Repositories provides Git version control to support collaborative development of any application or service. In this lab, you will create a local Git repository that contains a sample file, add a Google Source Repository as a remote, and push the contents of the local repository. You will use the source browser included in Source Repositories to view your repository files from within the Cloud Console.

Task 1: Create a new Cloud Source Repository named REPO_DEMO:

student_04_f3547d22d614@cloudshell:~ (qwiklabs-gcp-03-e1abab50929c)$ gcloud source repos create REPO_DEMO

Created [REPO_DEMO].
WARNING: You may be billed for this repository. See https://cloud.google.com/source-repositories/docs/pricing for details.
student_04_f3547d22d614@cloudshell:~ (qwiklabs-gcp-03-e1abab50929c)$ 


Task 2. Clone the new repository into your Cloud Shell session
Clone the contents of your new Cloud Source Repository to a local repo in your Cloud Shell session:

student_04_f3547d22d614@cloudshell:~ (qwiklabs-gcp-03-e1abab50929c)$ gcloud source repos clone REPO_DEMO

Cloning into '/home/student_04_f3547d22d614/REPO_DEMO'...
warning: You appear to have cloned an empty repository.
Project [qwiklabs-gcp-03-e1abab50929c] repository [REPO_DEMO] was cloned to [/home/student_04_f3547d22d614/REPO_DEMO].
student_04_f3547d22d614@cloudshell:~ (qwiklabs-gcp-03-e1abab50929c)$ 


student_04_f3547d22d614@cloudshell:~/REPO_DEMO (qwiklabs-gcp-03-e1abab50929c)$ gcloud source repos list
REPO_NAME: REPO_DEMO
PROJECT_ID: qwiklabs-gcp-03-e1abab50929c

student_04_f3547d22d614@cloudshell:~/REPO_DEMO (qwiklabs-gcp-03-e1abab50929c)$ git add myfile.txt
student_04_f3547d22d614@cloudshell:~/REPO_DEMO (qwiklabs-gcp-03-e1abab50929c)$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   myfile.txt

student_04_f3547d22d614@cloudshell:~/REPO_DEMO (qwiklabs-gcp-03-e1abab50929c)$ git commit -m "First file" myfile.txt
[master (root-commit) 5ad71da] First file
 1 file changed, 1 insertion(+)
 create mode 100644 myfile.txt
student_04_f3547d22d614@cloudshell:~/REPO_DEMO (qwiklabs-gcp-03-e1abab50929c)$ 
student_04_f3547d22d614@cloudshell:~/REPO_DEMO (qwiklabs-gcp-03-e1abab50929c)$ git status
On branch master
Your branch is based on 'origin/master', but the upstream is gone.
  (use "git branch --unset-upstream" to fixup)

nothing to commit, working tree clean
student_04_f3547d22d614@cloudshell:~/REPO_DEMO (qwiklabs-gcp-03-e1abab50929c)$ git branch
* master
student_04_f3547d22d614@cloudshell:~/REPO_DEMO (qwiklabs-gcp-03-e1abab50929c)$ git push origin master
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 222 bytes | 222.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Waiting for private key checker: 1/1 objects left
To https://source.developers.google.com/p/qwiklabs-gcp-03-e1abab50929c/r/REPO_DEMO
 * [new branch]      master -> master
student_04_f3547d22d614@cloudshell:~/REPO_DEMO (qwiklabs-gcp-03-e1abab50929c)$ 
student_04_f3547d22d614@cloudshell:~/REPO_DEMO (qwiklabs-gcp-03-e1abab50929c)$ 
student_04_f3547d22d614@cloudshell:~/REPO_DEMO (qwiklabs-gcp-03-e1abab50929c)$ 
student_04_f3547d22d614@cloudshell:~/REPO_DEMO (qwiklabs-gcp-03-e1abab50929c)$ gcloud source repos list
REPO_NAME: REPO_DEMO
PROJECT_ID: qwiklabs-gcp-03-e1abab50929c
URL: https://source.developers.google.com/p/qwiklabs-gcp-03-e1abab50929c/r/REPO_DEMO
student_04_f3547d22d614@cloudshell:~/REPO_DEMO (qwiklabs-gcp-03-e1abab50929c)$ history
    1  gcloud source repos create REPO_DEMO
    2  gcloud source repos clone REPO_DEMO
    3  cd REPO_DEMO/
    4  echo "Hello World" > myfile.txt
    5  git config --global user.email "ketan@example.com"
    6  git config --global user.name "ketan patel"
    7  git status
    8  git add myfile.txt
    9  git status
   10  git commit -m "First file" myfile.txt
   11  git status
   12  git branch
   13  git push origin master
   14  gcloud source repos list
   15  history
student_04_f3547d22d614




create a Data Fusion instance and deploy a sample pipeline

Create a Data Fusion instance and deploy a sample pipeline that reads an input file from Cloud Storage, transforms and filters the data to o...