Created
November 14, 2018 23:43
-
-
Save tmbdev/2a4d094ad9a23fbbe17894bd359dedde to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": 1, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "\n", | |
| "All components are up to date.\n", | |
| "yes: standard output: Broken pipe\n", | |
| "\n", | |
| "All components are up to date.\n", | |
| "yes: standard output: Broken pipe\n", | |
| "\n", | |
| "All components are up to date.\n", | |
| "yes: standard output: Broken pipe\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "yes | gcloud components update\n", | |
| "yes | gcloud components install kubectl\n", | |
| "yes | gcloud components install beta" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 2, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "PROJECT_ID NAME PROJECT_NUMBER\n", | |
| "nvlpr-research nvlpr 635569233476\n", | |
| "research-191823 Research 907859198744\n", | |
| "researchdesktop-192421 ResearchDesktop 706938655672\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "gcloud projects list" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 3, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "set -e\n", | |
| "[email protected]\n", | |
| "project=research-191823\n", | |
| "zone=us-central1-b\n", | |
| "cluster=testcluster\n", | |
| "image=gcr.io/$project/testimage" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 4, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "The following clusters will be deleted.\n", | |
| " - [testcluster] in [us-central1-a]\n", | |
| "\n", | |
| "Do you want to continue (Y/n)? \n", | |
| "\u001b[1;31mERROR:\u001b[0m (gcloud.container.clusters.delete) Some requests did not succeed:\n", | |
| " - args: [u\"ResponseError: code=404, message=Not found: projects/research-191823/zones/us-central1-a/clusters/testcluster.\\nNo cluster named 'testcluster' in research-191823.\"]\n", | |
| " exit_code: 1\n", | |
| " message: ResponseError: code=404, message=Not found: projects/research-191823/zones/us-central1-a/clusters/testcluster.\n", | |
| "No cluster named 'testcluster' in research-191823.\n", | |
| "\n", | |
| "yes: standard output: Broken pipe\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "yes | gcloud container clusters delete $cluster || true" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 5, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "Updated property [core/project].\n", | |
| "Updated property [compute/zone].\n", | |
| "\u001b[1;33mWARNING:\u001b[0m Starting in 1.12, new clusters will have basic authentication disabled by default. Basic authentication can be enabled (or disabled) manually using the `--[no-]enable-basic-auth` flag.\n", | |
| "\u001b[1;33mWARNING:\u001b[0m Starting in 1.12, new clusters will not have a client certificate issued. You can manually enable (or disable) the issuance of the client certificate using the `--[no-]issue-client-certificate` flag.\n", | |
| "\u001b[1;33mWARNING:\u001b[0m Currently VPC-native is not the default mode during cluster creation. In the future, this will become the default mode and can be disabled using `--no-enable-ip-alias` flag. Use `--[no-]enable-ip-alias` flag to suppress this warning.\n", | |
| "\u001b[1;33mWARNING:\u001b[0m Starting in 1.12, default node pools in new clusters will have their legacy Compute Engine instance metadata endpoints disabled by default. To create a cluster with legacy instance metadata endpoints disabled in the default node pool, run `clusters create` with the flag `--metadata disable-legacy-endpoints=true`.\n", | |
| "This will enable the autorepair feature for nodes. Please see https://cloud.google.com/kubernetes-engine/docs/node-auto-repair for more information on node autorepairs.\n", | |
| "Creating cluster testcluster in us-central1-b...done. \n", | |
| "Created [https://container.googleapis.com/v1/projects/research-191823/zones/us-central1-b/clusters/testcluster].\n", | |
| "To inspect the contents of your cluster, go to: https://console.cloud.google.com/kubernetes/workload_/gcloud/us-central1-b/testcluster?project=research-191823\n", | |
| "kubeconfig entry generated for testcluster.\n", | |
| "NAME LOCATION MASTER_VERSION MASTER_IP MACHINE_TYPE NODE_VERSION NUM_NODES STATUS\n", | |
| "testcluster us-central1-b 1.9.7-gke.11 35.184.158.196 n1-standard-1 1.9.7-gke.11 4 RUNNING\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "gcloud config set project $project\n", | |
| "gcloud config set compute/zone us-central1-b\n", | |
| "\n", | |
| "gcloud container clusters create $cluster --num-nodes=4" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 6, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS\n", | |
| "gke-amlp-default-pool-0bb18c21-43wc us-central1-a n1-standard-8 10.128.0.5 35.224.7.173 RUNNING\n", | |
| "gke-amlp-default-pool-0bb18c21-jvtw us-central1-a n1-standard-8 10.128.0.3 35.188.61.217 RUNNING\n", | |
| "gke-amlp-default-pool-0bb18c21-zcg8 us-central1-a n1-standard-8 10.128.0.2 35.202.117.64 RUNNING\n", | |
| "gke-amlp-default-pool-0bb18c21-zgm7 us-central1-a n1-standard-8 10.128.0.4 104.197.68.99 RUNNING\n", | |
| "gke-testcluster-default-pool-fa22edca-32jp us-central1-b n1-standard-1 10.128.0.6 35.202.7.174 RUNNING\n", | |
| "gke-testcluster-default-pool-fa22edca-6zzk us-central1-b n1-standard-1 10.128.0.7 35.239.235.169 RUNNING\n", | |
| "gke-testcluster-default-pool-fa22edca-t83t us-central1-b n1-standard-1 10.128.0.9 35.184.192.46 RUNNING\n", | |
| "gke-testcluster-default-pool-fa22edca-w0w4 us-central1-b n1-standard-1 10.128.0.8 35.226.156.117 RUNNING\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "gcloud compute instances list" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 7, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "pod \"busybox\" created\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "kubectl create -f - <<EOF\n", | |
| "---\n", | |
| "apiVersion: v1\n", | |
| "kind: Pod\n", | |
| "metadata:\n", | |
| " name: busybox\n", | |
| " labels:\n", | |
| " app: busybox\n", | |
| "spec:\n", | |
| " containers:\n", | |
| " - name: busybox\n", | |
| " image: busybox\n", | |
| " command: [\"sleep\"]\n", | |
| " args: [\"1000000\"]\n", | |
| " restartPolicy: Always\n", | |
| " hostname: \"busybox\"\n", | |
| "EOF" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 8, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "pod \"busybox2\" created\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "kubectl create -f - <<EOF\n", | |
| "---\n", | |
| "apiVersion: v1\n", | |
| "kind: Pod\n", | |
| "metadata:\n", | |
| " name: busybox2\n", | |
| " labels:\n", | |
| " app: busybox2\n", | |
| "spec:\n", | |
| " containers:\n", | |
| " - name: busybox2\n", | |
| " image: busybox\n", | |
| " command: [\"sleep\"]\n", | |
| " args: [\"1000000\"]\n", | |
| " restartPolicy: Always\n", | |
| " hostname: \"busybox2\"\n", | |
| "EOF" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 10, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "service \"busybox2\" created\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "kubectl create -f - <<EOF\n", | |
| "---\n", | |
| "kind: Service\n", | |
| "apiVersion: v1\n", | |
| "metadata:\n", | |
| " name: busybox2\n", | |
| "spec:\n", | |
| " selector:\n", | |
| " app: busybox2\n", | |
| " ports:\n", | |
| " - protocol: TCP\n", | |
| " port: 80\n", | |
| " targetPort: 80\n", | |
| "EOF" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 12, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "NAME READY STATUS RESTARTS AGE\n", | |
| "busybox 1/1 Running 0 1m\n", | |
| "busybox2 1/1 Running 0 1m\n", | |
| "NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE\n", | |
| "busybox2 ClusterIP 10.39.253.31 <none> 80/TCP 12s\n", | |
| "kubernetes ClusterIP 10.39.240.1 <none> 443/TCP 2m\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "kubectl get pods\n", | |
| "kubectl get services" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 13, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "Server:\t\t10.39.240.10\n", | |
| "Address:\t10.39.240.10:53\n", | |
| "\n", | |
| "** server can't find busybox2: NXDOMAIN\n", | |
| "\n", | |
| "*** Can't find busybox2: No answer\n", | |
| "\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "kubectl exec busybox -- nslookup busybox2" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 14, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "Server:\t\t10.39.240.10\n", | |
| "Address:\t10.39.240.10:53\n", | |
| "\n", | |
| "** server can't find kubernetes.default: NXDOMAIN\n", | |
| "\n", | |
| "*** Can't find kubernetes.default: No answer\n", | |
| "\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "kubectl exec busybox -- nslookup kubernetes.default" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 15, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "Server:\t\t10.39.240.10\n", | |
| "Address:\t10.39.240.10:53\n", | |
| "\n", | |
| "** server can't find kubernetes: NXDOMAIN\n", | |
| "\n", | |
| "*** Can't find kubernetes: No answer\n", | |
| "\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "kubectl exec busybox -- nslookup kubernetes" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 16, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "nameserver 10.39.240.10\n", | |
| "search default.svc.cluster.local svc.cluster.local cluster.local c.research-191823.internal google.internal\n", | |
| "options ndots:5\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "kubectl exec busybox -- cat /etc/resolv.conf" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Bash", | |
| "language": "bash", | |
| "name": "bash" | |
| }, | |
| "language_info": { | |
| "codemirror_mode": "shell", | |
| "file_extension": ".sh", | |
| "mimetype": "text/x-sh", | |
| "name": "bash" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 2 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment