update tabs shortcode

This commit is contained in:
Karen Bradshaw 2020-04-27 16:04:40 -04:00
parent de78f4984c
commit 7a98007a29
3 changed files with 200 additions and 146 deletions

View File

@ -37,9 +37,11 @@ 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:
```
@ -48,51 +50,68 @@ This brief demo guides you on how to start, use, and delete Minikube locally. Fo
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).
Lets 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
```
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
```
5. Get the URL of the exposed Service to view the Service details:
```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
@ -119,34 +138,50 @@ This brief demo guides you on how to start, use, and delete Minikube locally. Fo
Request Body:
-no body in request-
```
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
```
8. Delete the `hello-minikube` Deployment:
```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).
10. Delete the local Minikube cluster:
```shell
minikube delete
```

View File

@ -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 <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
@ -89,17 +90,23 @@ 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
@ -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,6 +152,7 @@ If you are on macOS and using [Homebrew](https://brew.sh/) package manager, you
```
brew install kubectl
```
or
```
@ -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`.
@ -209,9 +220,10 @@ If you are on Windows and using [Powershell Gallery](https://www.powershellgalle
install-kubectl.ps1 [-DownloadLocation <path>]
```
{{< note >}}If you do not specify a `DownloadLocation`, `kubectl` will be installed in the user's temp Directory.{{< /note >}}
{{< 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
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:
```
@ -272,6 +289,7 @@ To install kubectl on Windows you can use either [Chocolatey](https://chocolatey
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,13 +369,12 @@ 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
@ -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
@ -455,7 +473,7 @@ 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.
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.
@ -489,6 +507,7 @@ compinit
{{% /tab %}}
{{< /tabs >}}
{{% /capture %}}
{{% capture whatsnext %}}

View File

@ -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 -}}
<div id="{{ $tab_set_id }}">
<ul>
{{ range $i, $e := $tabs }}
{{ $id := printf "%s-%d" $tab_set_id $i }}
<li><a href="#{{ $id }}">{{ trim .name " " }}</a></li>
{{ end }}
{{- range $i, $e := $tabs -}}
{{- $id := printf "%s-%d" $tab_set_id $i -}}
<li><a href="#{{ $id }}">{{- trim .name " " -}}</a></li>
{{- end -}}
</ul>
{{ range $i, $e := $tabs }}
{{ $id := printf "%s-%d" $tab_set_id $i }}
{{- range $i, $e := $tabs -}}
{{- $id := printf "%s-%d" $tab_set_id $i -}}
<div id="{{ $id }}">
{{ 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 -}}
</div>
{{ end }}
{{- end -}}
</div>
{{ $elem := $tab_set_id | safeJS }}
{{- $elem := $tab_set_id | safeJS -}}
<script>$(function(){$("#{{ $elem }}").tabs();});</script>