From 7a98007a293d7865dd0d539b038e2064eb123cb1 Mon Sep 17 00:00:00 2001 From: Karen Bradshaw Date: Mon, 27 Apr 2020 16:04:40 -0400 Subject: [PATCH] update tabs shortcode --- .../setup/learning-environment/minikube.md | 213 ++++++++++-------- .../en/docs/tasks/tools/install-kubectl.md | 59 +++-- layouts/shortcodes/tabs.html | 74 +++--- 3 files changed, 200 insertions(+), 146 deletions(-) diff --git a/content/en/docs/setup/learning-environment/minikube.md b/content/en/docs/setup/learning-environment/minikube.md index ec8514c84c..e314d56608 100644 --- a/content/en/docs/setup/learning-environment/minikube.md +++ b/content/en/docs/setup/learning-environment/minikube.md @@ -37,116 +37,151 @@ See [Installing Minikube](/docs/tasks/tools/install-minikube/). This brief demo guides you on how to start, use, and delete Minikube locally. Follow the steps given below to start and explore Minikube. 1. Start Minikube and create a cluster: - ```shell - minikube start - ``` - The output is similar to this: - ``` - Starting local Kubernetes cluster... - Running pre-create checks... - Creating machine... - Starting local Kubernetes cluster... - ``` - For more information on starting your cluster on a specific Kubernetes version, VM, or container runtime, see [Starting a Cluster](#starting-a-cluster). + ```shell + minikube start + ``` + + The output is similar to this: + + ``` + Starting local Kubernetes cluster... + Running pre-create checks... + Creating machine... + Starting local Kubernetes cluster... + ``` + + For more information on starting your cluster on a specific Kubernetes version, VM, or container runtime, see [Starting a Cluster](#starting-a-cluster). 2. Now, you can interact with your cluster using kubectl. For more information, see [Interacting with Your Cluster](#interacting-with-your-cluster). - Let’s create a Kubernetes Deployment using an existing image named `echoserver`, which is a simple HTTP server and expose it on port 8080 using `--port`. - ```shell - kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.10 - ``` - The output is similar to this: - ``` - deployment.apps/hello-minikube created - ``` -3. To access the `hello-minikube` Deployment, expose it as a Service: - ```shell - kubectl expose deployment hello-minikube --type=NodePort --port=8080 - ``` - The option `--type=NodePort` specifies the type of the Service. + Let’s create a Kubernetes Deployment using an existing image named `echoserver`, which is a simple HTTP server and expose it on port 8080 using `--port`. + + ```shell + kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.10 + ``` + + The output is similar to this: + + ``` + deployment.apps/hello-minikube created + ``` +3. To access the `hello-minikube` Deployment, expose it as a Service: + + ```shell + kubectl expose deployment hello-minikube --type=NodePort --port=8080 + ``` + + The option `--type=NodePort` specifies the type of the Service. + + The output is similar to this: + + ``` + service/hello-minikube exposed + ``` - The output is similar to this: - ``` - service/hello-minikube exposed - ``` 4. The `hello-minikube` Pod is now launched but you have to wait until the Pod is up before accessing it via the exposed Service. - Check if the Pod is up and running: - ```shell - kubectl get pod - ``` - If the output shows the `STATUS` as `ContainerCreating`, the Pod is still being created: - ``` - NAME READY STATUS RESTARTS AGE - hello-minikube-3383150820-vctvh 0/1 ContainerCreating 0 3s - ``` - If the output shows the `STATUS` as `Running`, the Pod is now up and running: - ``` - NAME READY STATUS RESTARTS AGE - hello-minikube-3383150820-vctvh 1/1 Running 0 13s - ``` + Check if the Pod is up and running: + + ```shell + kubectl get pod + ``` + + If the output shows the `STATUS` as `ContainerCreating`, the Pod is still being created: + + ``` + NAME READY STATUS RESTARTS AGE + hello-minikube-3383150820-vctvh 0/1 ContainerCreating 0 3s + ``` + + If the output shows the `STATUS` as `Running`, the Pod is now up and running: + + ``` + NAME READY STATUS RESTARTS AGE + hello-minikube-3383150820-vctvh 1/1 Running 0 13s + ``` + 5. Get the URL of the exposed Service to view the Service details: - ```shell - minikube service hello-minikube --url - ``` + + ```shell + minikube service hello-minikube --url + ``` + 6. To view the details of your local cluster, copy and paste the URL you got as the output, on your browser. - The output is similar to this: - ``` - Hostname: hello-minikube-7c77b68cff-8wdzq + The output is similar to this: - Pod Information: - -no pod information available- + ``` + Hostname: hello-minikube-7c77b68cff-8wdzq - Server values: - server_version=nginx: 1.13.3 - lua: 10008 + Pod Information: + -no pod information available- - Request Information: - client_address=172.17.0.1 - method=GET - real path=/ - query= - request_version=1.1 - request_scheme=http - request_uri=http://192.168.99.100:8080/ + Server values: + server_version=nginx: 1.13.3 - lua: 10008 - Request Headers: + Request Information: + client_address=172.17.0.1 + method=GET + real path=/ + query= + request_version=1.1 + request_scheme=http + request_uri=http://192.168.99.100:8080/ + + Request Headers: accept=*/* host=192.168.99.100:30674 user-agent=curl/7.47.0 - Request Body: + Request Body: -no body in request- - ``` - If you no longer want the Service and cluster to run, you can delete them. + ``` + + If you no longer want the Service and cluster to run, you can delete them. + 7. Delete the `hello-minikube` Service: - ```shell - kubectl delete services hello-minikube - ``` - The output is similar to this: - ``` - service "hello-minikube" deleted - ``` + + ```shell + kubectl delete services hello-minikube + ``` + + The output is similar to this: + + ``` + service "hello-minikube" deleted + ``` + 8. Delete the `hello-minikube` Deployment: - ```shell - kubectl delete deployment hello-minikube - ``` - The output is similar to this: - ``` - deployment.extensions "hello-minikube" deleted - ``` + + ```shell + kubectl delete deployment hello-minikube + ``` + + The output is similar to this: + + ``` + deployment.extensions "hello-minikube" deleted + ``` + 9. Stop the local Minikube cluster: - ```shell - minikube stop - ``` - The output is similar to this: - ``` - Stopping "minikube"... - "minikube" stopped. - ``` - For more information, see [Stopping a Cluster](#stopping-a-cluster). + + ```shell + minikube stop + ``` + + The output is similar to this: + + ``` + Stopping "minikube"... + "minikube" stopped. + ``` + + For more information, see [Stopping a Cluster](#stopping-a-cluster). + 10. Delete the local Minikube cluster: + ```shell minikube delete ``` @@ -193,8 +228,8 @@ For example the command would be. minikube start --driver= ``` Minikube supports the following drivers: - {{< note >}} - See [DRIVERS](https://minikube.sigs.k8s.io/docs/reference/drivers/) for details on supported drivers and how to install +{{< note >}} +See [DRIVERS](https://minikube.sigs.k8s.io/docs/reference/drivers/) for details on supported drivers and how to install plugins. {{< /note >}} diff --git a/content/en/docs/tasks/tools/install-kubectl.md b/content/en/docs/tasks/tools/install-kubectl.md index 6d9ffdcd0a..131362109a 100644 --- a/content/en/docs/tasks/tools/install-kubectl.md +++ b/content/en/docs/tasks/tools/install-kubectl.md @@ -65,6 +65,7 @@ echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/ sudo apt-get update sudo apt-get install -y kubectl {{< /tab >}} + {{< tab name="CentOS, RHEL or Fedora" codelang="bash" >}}cat < /etc/yum.repos.d/kubernetes.repo [kubernetes] name=Kubernetes @@ -89,24 +90,30 @@ snap install kubectl --classic kubectl version --client ``` + {{% /tab %}} + {{% tab name="Homebrew" %}} If you are on Linux and using [Homebrew](https://docs.brew.sh/Homebrew-on-Linux) package manager, kubectl is available for [installation](https://docs.brew.sh/Homebrew-on-Linux#install). + ```shell brew install kubectl kubectl version --client ``` + {{% /tab %}} + {{< /tabs >}} + ## Install kubectl on macOS ### Install kubectl binary with curl on macOS 1. Download the latest release: - ``` + ``` curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/darwin/amd64/kubectl" ``` @@ -129,6 +136,7 @@ kubectl version --client ``` sudo mv ./kubectl /usr/local/bin/kubectl ``` + 4. Test to ensure the version you installed is up-to-date: ``` @@ -144,8 +152,9 @@ If you are on macOS and using [Homebrew](https://brew.sh/) package manager, you ``` brew install kubectl ``` - or - + + or + ``` brew install kubernetes-cli ``` @@ -188,11 +197,13 @@ If you are on macOS and using [Macports](https://macports.org/) package manager, To find out the latest stable version (for example, for scripting), take a look at [https://storage.googleapis.com/kubernetes-release/release/stable.txt](https://storage.googleapis.com/kubernetes-release/release/stable.txt). 2. Add the binary in to your PATH. + 3. Test to ensure the version of `kubectl` is the same as downloaded: ``` kubectl version --client ``` + {{< note >}} [Docker Desktop for Windows](https://docs.docker.com/docker-for-windows/#kubernetes) adds its own version of `kubectl` to PATH. If you have installed Docker Desktop before, you may need to place your PATH entry before the one added by the Docker Desktop installer or remove the Docker Desktop's `kubectl`. @@ -208,10 +219,11 @@ If you are on Windows and using [Powershell Gallery](https://www.powershellgalle Install-Script -Name install-kubectl -Scope CurrentUser -Force install-kubectl.ps1 [-DownloadLocation ] ``` - - {{< note >}}If you do not specify a `DownloadLocation`, `kubectl` will be installed in the user's temp Directory.{{< /note >}} - - The installer creates `$HOME/.kube` and instructs it to create a config file + +{{< note >}}If you do not specify a `DownloadLocation`, `kubectl` will be installed in the user's temp Directory. +{{< /note >}} + + The installer creates `$HOME/.kube` and instructs it to create a config file. 2. Test to ensure the version you installed is up-to-date: @@ -219,11 +231,14 @@ If you are on Windows and using [Powershell Gallery](https://www.powershellgalle kubectl version --client ``` - {{< note >}}Updating the installation is performed by rerunning the two commands listed in step 1.{{< /note >}} +{{< note >}} +Updating the installation is performed by rerunning the two commands listed in step 1. +{{< /note >}} ### Install on Windows using Chocolatey or Scoop -To install kubectl on Windows you can use either [Chocolatey](https://chocolatey.org) package manager or [Scoop](https://scoop.sh) command-line installer. +1. To install kubectl on Windows you can use either [Chocolatey](https://chocolatey.org) package manager or [Scoop](https://scoop.sh) command-line installer. + {{< tabs name="kubectl_win_install" >}} {{% tab name="choco" %}} @@ -236,6 +251,8 @@ To install kubectl on Windows you can use either [Chocolatey](https://chocolatey {{% /tab %}} {{< /tabs >}} + + 2. Test to ensure the version you installed is up-to-date: ``` @@ -265,13 +282,14 @@ To install kubectl on Windows you can use either [Chocolatey](https://chocolatey New-Item config -type file ``` - {{< note >}}Edit the config file with a text editor of your choice, such as Notepad.{{< /note >}} +{{< note >}}Edit the config file with a text editor of your choice, such as Notepad.{{< /note >}} ## Download as part of the Google Cloud SDK You can install kubectl as part of the Google Cloud SDK. 1. Install the [Google Cloud SDK](https://cloud.google.com/sdk/). + 2. Run the `kubectl` installation command: ``` @@ -293,6 +311,7 @@ Check that kubectl is properly configured by getting the cluster state: ```shell kubectl cluster-info ``` + If you see a URL response, kubectl is correctly configured to access your cluster. If you see a message similar to the following, kubectl is not configured correctly or is not able to connect to a Kubernetes cluster. @@ -350,18 +369,17 @@ You now need to ensure that the kubectl completion script gets sourced in all yo ```shell echo 'source <(kubectl completion bash)' >>~/.bashrc ``` - - Add the completion script to the `/etc/bash_completion.d` directory: ```shell kubectl completion bash >/etc/bash_completion.d/kubectl ``` -- If you have an alias for kubectl, you can extend shell completion to work with that alias: +If you have an alias for kubectl, you can extend shell completion to work with that alias: - ```shell - echo 'alias k=kubectl' >>~/.bashrc - echo 'complete -F __start_kubectl k' >>~/.bashrc - ``` +```shell +echo 'alias k=kubectl' >>~/.bashrc +echo 'complete -F __start_kubectl k' >>~/.bashrc +``` {{< note >}} bash-completion sources all completion scripts in `/etc/bash_completion.d`. @@ -382,7 +400,7 @@ The kubectl completion script for Bash can be generated with `kubectl completion However, the kubectl completion script depends on [**bash-completion**](https://github.com/scop/bash-completion) which you thus have to previously install. {{< warning>}} -there are two versions of bash-completion, v1 and v2. V1 is for Bash 3.2 (which is the default on macOS), and v2 is for Bash 4.1+. The kubectl completion script **doesn't work** correctly with bash-completion v1 and Bash 3.2. It requires **bash-completion v2** and **Bash 4.1+**. Thus, to be able to correctly use kubectl completion on macOS, you have to install and use Bash 4.1+ ([*instructions*](https://itnext.io/upgrading-bash-on-macos-7138bd1066ba)). The following instructions assume that you use Bash 4.1+ (that is, any Bash version of 4.1 or newer). +There are two versions of bash-completion, v1 and v2. V1 is for Bash 3.2 (which is the default on macOS), and v2 is for Bash 4.1+. The kubectl completion script **doesn't work** correctly with bash-completion v1 and Bash 3.2. It requires **bash-completion v2** and **Bash 4.1+**. Thus, to be able to correctly use kubectl completion on macOS, you have to install and use Bash 4.1+ ([*instructions*](https://itnext.io/upgrading-bash-on-macos-7138bd1066ba)). The following instructions assume that you use Bash 4.1+ (that is, any Bash version of 4.1 or newer). {{< /warning >}} ### Upgrade Bash @@ -454,9 +472,9 @@ You now have to ensure that the kubectl completion script gets sourced in all yo - If you installed kubectl with Homebrew (as explained [above](#install-with-homebrew-on-macos)), then the kubectl completion script should already be in `/usr/local/etc/bash_completion.d/kubectl`. In that case, you don't need to do anything. -{{< note >}} -the Homebrew installation of bash-completion v2 sources all the files in the `BASH_COMPLETION_COMPAT_DIR` directory, that's why the latter two methods work. -{{< /note >}} + {{< note >}} + The Homebrew installation of bash-completion v2 sources all the files in the `BASH_COMPLETION_COMPAT_DIR` directory, that's why the latter two methods work. + {{< /note >}} In any case, after reloading your shell, kubectl completion should be working. {{% /tab %}} @@ -489,6 +507,7 @@ compinit {{% /tab %}} {{< /tabs >}} + {{% /capture %}} {{% capture whatsnext %}} diff --git a/layouts/shortcodes/tabs.html b/layouts/shortcodes/tabs.html index cfb6246aae..7abe6c14e8 100644 --- a/layouts/shortcodes/tabs.html +++ b/layouts/shortcodes/tabs.html @@ -1,43 +1,43 @@ -{{ .Page.Scratch.Add "tabset-counter" 1 }} -{{ $tab_set_id := .Get "name" | default (printf "tabset-%s-%d" (.Page.RelPermalink) (.Page.Scratch.Get "tabset-counter") ) | anchorize }} -{{ $tabs := .Scratch.Get "tabs" }} -{{ if .Inner }}{{/* We don't use the inner content, but Hugo will complain if we don't reference it. */}}{{ end }} +{{- .Page.Scratch.Add "tabset-counter" 1 -}} +{{- $tab_set_id := .Get "name" | default (printf "tabset-%s-%d" (.Page.RelPermalink) (.Page.Scratch.Get "tabset-counter") ) | anchorize -}} +{{- $tabs := .Scratch.Get "tabs" -}} +{{- if .Inner -}}{{- /* We don't use the inner content, but Hugo will complain if we don't reference it. */ -}}{{- end -}}
    - {{ range $i, $e := $tabs }} - {{ $id := printf "%s-%d" $tab_set_id $i }} -
  • {{ trim .name " " }}
  • -{{ end }} + {{- range $i, $e := $tabs -}} + {{- $id := printf "%s-%d" $tab_set_id $i -}} +
  • {{- trim .name " " -}}
  • +{{- end -}}
-{{ range $i, $e := $tabs }} -{{ $id := printf "%s-%d" $tab_set_id $i }} +{{- range $i, $e := $tabs -}} +{{- $id := printf "%s-%d" $tab_set_id $i -}}
- {{ with .content }} - {{ . }} - {{ else }} - {{ if eq $.Page.BundleType "leaf" }} - {{/* find the file somewhere inside the bundle. Note the use of double asterisk */}} - {{ with $.Page.Resources.GetMatch (printf "**%s*" .include) }} - {{ if ne .ResourceType "page" }} - {{/* Assume it is a file that needs code highlighting. */}} - {{ $codelang := $e.codelang | default ( path.Ext .Name | strings.TrimPrefix ".") }} - {{ highlight .Content $codelang "" }} - {{ else}} - {{ .Content }} - {{ end }} - {{ end }} - {{ else}} - {{ $path := path.Join $.Page.File.Dir .include }} - {{ $page := site.GetPage "page" $path }} - {{ with $page }} - {{ .Content }} - {{ else }} - {{ errorf "[%s] tabs include not found for path %q" site.Language.Lang $path}} - {{ end }} - {{ end }} - {{ end }} + {{- with .content -}} + {{- . -}} + {{- else -}} + {{- if eq $.Page.BundleType "leaf" -}} + {{- /* find the file somewhere inside the bundle. Note the use of double asterisk */ -}} + {{- with $.Page.Resources.GetMatch (printf "**%s*" .include) -}} + {{- if ne .ResourceType "page" -}} + {{- /* Assume it is a file that needs code highlighting. */ -}} + {{- $codelang := $e.codelang | default ( path.Ext .Name | strings.TrimPrefix ".") -}} + {{- highlight .Content $codelang "" -}} + {{- else -}} + {{- .Content -}} + {{- end -}} + {{- end -}} + {{- else -}} + {{- $path := path.Join $.Page.File.Dir .include -}} + {{- $page := site.GetPage "page" $path -}} + {{- with $page -}} + {{- .Content -}} + {{- else -}} + {{- errorf "[%s] tabs include not found for path %q" site.Language.Lang $path -}} + {{- end -}} + {{- end -}} + {{- end -}}
-{{ end }} +{{- end -}}
-{{ $elem := $tab_set_id | safeJS }} - +{{- $elem := $tab_set_id | safeJS -}} + \ No newline at end of file