Created
November 14, 2018 18:52
-
-
Save tmbdev/4cd07d23a05804610acad6995f5a318d 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", | |
| "tmbgpu tmbgpu 534830068186\n", | |
| "tmbmicro tmbmicro 577226705806\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "gcloud projects list" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 5, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "set -e\n", | |
| "[email protected]\n", | |
| "project=tmbmicro\n", | |
| "zone=us-central1-b\n", | |
| "cluster=testcluster\n", | |
| "image=gcr.io/$project/testimage" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 6, | |
| "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/tmbgpu/zones/us-central1-a/clusters/testcluster.\\nNo cluster named 'testcluster' in tmbgpu.\"]\n", | |
| " exit_code: 1\n", | |
| " message: ResponseError: code=404, message=Not found: projects/tmbgpu/zones/us-central1-a/clusters/testcluster.\n", | |
| "No cluster named 'testcluster' in tmbgpu.\n", | |
| "\n", | |
| "yes: standard output: Broken pipe\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "yes | gcloud container clusters delete $cluster || true" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 7, | |
| "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/tmbmicro/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=tmbmicro\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 104.197.152.208 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": 8, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS\n", | |
| "gke-testcluster-default-pool-34cd877f-7f7q us-central1-b n1-standard-1 10.128.0.5 104.198.50.125 RUNNING\n", | |
| "gke-testcluster-default-pool-34cd877f-d67d us-central1-b n1-standard-1 10.128.0.2 35.239.64.14 RUNNING\n", | |
| "gke-testcluster-default-pool-34cd877f-h0hw us-central1-b n1-standard-1 10.128.0.3 104.197.114.110 RUNNING\n", | |
| "gke-testcluster-default-pool-34cd877f-zs6m us-central1-b n1-standard-1 10.128.0.4 35.226.126.220 RUNNING\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "gcloud compute instances list" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 9, | |
| "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": 10, | |
| "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": 13, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "NAME READY STATUS RESTARTS AGE\n", | |
| "busybox 1/1 Running 0 56s\n", | |
| "busybox2 1/1 Running 0 55s\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "kubectl get pods" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 12, | |
| "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": [ | |
| "nameserver 10.39.240.10\n", | |
| "search default.svc.cluster.local svc.cluster.local cluster.local c.tmbmicro.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