Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save SC0nner/09cf3749b4b45371c3fad7b44dd49d48 to your computer and use it in GitHub Desktop.

Select an option

Save SC0nner/09cf3749b4b45371c3fad7b44dd49d48 to your computer and use it in GitHub Desktop.

Revisions

  1. @dimitardanailov dimitardanailov revised this gist Sep 26, 2018. 1 changed file with 42 additions and 1 deletion.
    43 changes: 42 additions & 1 deletion google-compute-engine.md
    Original file line number Diff line number Diff line change
    @@ -133,4 +133,45 @@ bq mk <data-set-name>
    ```bash
    # Create table from txt file
    bq load babynames.names2010 yob2010.txt name:string,gender:string,count:integer
    ```
    ```

    ### BigTable

    ##### Configuration

    ```bash
    echo project = [PROJECT_ID] > ~/.cbtrc
    echo instance = quickstart-instance >> ~/.cbtrc
    ```

    ##### Read and Write Data

    ```bash
    # Create a table named my-table
    cbt createtable my-table
    ```

    ```bash
    # Add one column family named cf1
    cbt createfamily my-table cf1
    ```

    ```bash
    # List your column families
    cbt ls my-table
    ```

    ```bash
    # Put the value test-value in the row r1, using the column family cf1 and the column qualifier c1:
    cbt set my-table r1 cf1:c1=test-value
    ```

    ```bash
    # Use the cbt read command to read the data you added to the table:
    cbt read my-table
    ```

    ```bash
    # Delete the table my-table:
    cbt deletetable my-table
    ```
  2. @dimitardanailov dimitardanailov revised this gist Sep 26, 2018. 1 changed file with 14 additions and 0 deletions.
    14 changes: 14 additions & 0 deletions google-compute-engine.md
    Original file line number Diff line number Diff line change
    @@ -119,4 +119,18 @@ kubectl edit deployment hello-node
    ```bash
    gsutil cp yob2014.txt gs://<your_bucket>
    ```

    ### Big Query

    > Use the `bq ls` command to see whether your default project has any existing datasets.
    ```bash
    # Create a new dataset
    bq mk <data-set-name>
    ```

    ```bash
    # Create table from txt file
    bq load babynames.names2010 yob2010.txt name:string,gender:string,count:integer
    ```
  3. @dimitardanailov dimitardanailov revised this gist Sep 26, 2018. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions google-compute-engine.md
    Original file line number Diff line number Diff line change
    @@ -111,4 +111,12 @@ kubectl scale deployment hello-node --replicas=4

    ```bash
    kubectl edit deployment hello-node
    ```

    ### Storage

    > In Cloud Shell, run the following to move file yob2014.txt into your bucket. Replace <your_bucket> with the name of the bucket you just created:
    ```bash
    gsutil cp yob2014.txt gs://<your_bucket>
    ```
  4. @dimitardanailov dimitardanailov revised this gist Sep 26, 2018. 1 changed file with 37 additions and 0 deletions.
    37 changes: 37 additions & 0 deletions google-compute-engine.md
    Original file line number Diff line number Diff line change
    @@ -74,4 +74,41 @@ kubectl run hello-node \
    ```bash
    # To view the deployment, run:
    kubectl get deployments
    ```

    ```bash
    # To view the pod created by the deployment, run:
    kubectl get pods
    ```

    ##### Kubernates basic commands

    ```bash
    kubectl cluster-info
    kubectl config view
    kubectl get events
    kubectl logs <pod-name>
    ```

    ##### Allow external traffic

    ```bash
    kubectl expose deployment hello-node --type="LoadBalancer"
    ```

    ```bash
    # To find the publicly-accessible IP address of the service, request kubectl to list all the cluster services:
    kubectl get services
    ```

    ##### Scale up your service

    ```bash
    kubectl scale deployment hello-node --replicas=4
    ```

    ##### Roll out an upgrade to your service

    ```bash
    kubectl edit deployment hello-node
    ```
  5. @dimitardanailov dimitardanailov revised this gist Sep 26, 2018. 1 changed file with 28 additions and 0 deletions.
    28 changes: 28 additions & 0 deletions google-compute-engine.md
    Original file line number Diff line number Diff line change
    @@ -46,4 +46,32 @@ sudo mount -o discard,defaults /dev/disk/by-id/scsi-0Google_PersistentDisk_persi
    docker build -t gcr.io/PROJECT_ID/hello-node:v1 .
    docker run -d -p 8080:8080 gcr.io/PROJECT_ID/hello-node:v1
    gcloud docker -- push gcr.io/PROJECT_ID/hello-node:v1
    ```

    ### Kubernates

    ##### Create your cluster

    ```bash
    gcloud config set project PROJECT_ID
    ```

    ```bash
    gcloud container clusters create hello-world \
    --num-nodes 2 \
    --machine-type n1-standard-1 \
    --zone us-central1-a
    ```

    ##### Create your pod

    ```bash
    kubectl run hello-node \
    --image=gcr.io/PROJECT_ID/hello-node:v1 \
    --port=8080
    ```

    ```bash
    # To view the deployment, run:
    kubectl get deployments
    ```
  6. @dimitardanailov dimitardanailov revised this gist Sep 26, 2018. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions google-compute-engine.md
    Original file line number Diff line number Diff line change
    @@ -36,4 +36,14 @@ sudo mkfs.ext4 -F -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/disk/by

    # Step 3
    sudo mount -o discard,defaults /dev/disk/by-id/scsi-0Google_PersistentDisk_persistent-disk-1 /mnt/mydisk
    ```

    ### Docker

    ##### Create a Docker container image

    ```bash
    docker build -t gcr.io/PROJECT_ID/hello-node:v1 .
    docker run -d -p 8080:8080 gcr.io/PROJECT_ID/hello-node:v1
    gcloud docker -- push gcr.io/PROJECT_ID/hello-node:v1
    ```
  7. @dimitardanailov dimitardanailov revised this gist Sep 25, 2018. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions google-compute-engine.md
    Original file line number Diff line number Diff line change
    @@ -33,4 +33,7 @@ sudo mkdir /mnt/mydisk

    # Step 2
    sudo mkfs.ext4 -F -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/disk/by-id/scsi-0Google_PersistentDisk_persistent-disk-1

    # Step 3
    sudo mount -o discard,defaults /dev/disk/by-id/scsi-0Google_PersistentDisk_persistent-disk-1 /mnt/mydisk
    ```
  8. @dimitardanailov dimitardanailov revised this gist Sep 25, 2018. 1 changed file with 11 additions and 0 deletions.
    11 changes: 11 additions & 0 deletions google-compute-engine.md
    Original file line number Diff line number Diff line change
    @@ -22,4 +22,15 @@ gcloud compute instances attach-disk gcelab --disk mydisk --zone us-central1-c
    ##### Finding the persistent disk in the virtual machine
    ```bash
    gcloud compute ssh gcelab --zone us-central1-c
    ```

    ##### Formatting and mounting the persistent disk

    ```bash

    # Step 1
    sudo mkdir /mnt/mydisk

    # Step 2
    sudo mkfs.ext4 -F -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/disk/by-id/scsi-0Google_PersistentDisk_persistent-disk-1
    ```
  9. @dimitardanailov dimitardanailov revised this gist Sep 25, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion google-compute-engine.md
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ gcloud compute disks create mydisk --size=200GB \
    --zone us-central1-c
    ```

    # Attaching a disk
    ##### Attaching a disk

    ```bash
    gcloud compute instances attach-disk gcelab --disk mydisk --zone us-central1-c
  10. @dimitardanailov dimitardanailov revised this gist Sep 25, 2018. 1 changed file with 15 additions and 2 deletions.
    17 changes: 15 additions & 2 deletions google-compute-engine.md
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,22 @@
    ### Creating a Persistent Disk

    ##### Create a new instance
    ##### Create a new instance

    ```bash
    gcloud compute instances attach-disk gcelabtest --disk mydisk --zone us-central1-c
    gcloud compute instances create gcelab --zone us-central1-c
    ```

    ##### Create a new persistent disk

    ```bash
    gcloud compute disks create mydisk --size=200GB \
    --zone us-central1-c
    ```

    # Attaching a disk

    ```bash
    gcloud compute instances attach-disk gcelab --disk mydisk --zone us-central1-c
    ```

    ##### Finding the persistent disk in the virtual machine
  11. @dimitardanailov dimitardanailov created this gist Sep 25, 2018.
    12 changes: 12 additions & 0 deletions google-compute-engine.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    ### Creating a Persistent Disk

    ##### Create a new instance

    ```bash
    gcloud compute instances attach-disk gcelabtest --disk mydisk --zone us-central1-c
    ```

    ##### Finding the persistent disk in the virtual machine
    ```bash
    gcloud compute ssh gcelab --zone us-central1-c
    ```