提交 f6a770e0 编写于 作者: E edtrist

Add missing language to code blocks

上级 2c6dc34f
......@@ -9,23 +9,33 @@ description: >
To create an addon, first fork the minikube repository, and check out your fork:
`git clone git@github.com:<username>/minikube.git`
```shell
git clone git@github.com:<username>/minikube.git
```
Then go into the source directory:
`cd minikube`
```shell
cd minikube
```
Create a subdirectory:
`mkdir deploy/addons/<addon name>`
```shell
mkdir deploy/addons/<addon name>
```
Add your manifest YAML's to the directory you have created:
`cp *.yaml deploy/addons/<addon name>`
```shell
cp *.yaml deploy/addons/<addon name>
```
Note: If the addon never needs authentication to GCP, then consider adding the following label to the pod's yaml:
`gcp-auth-skip-secret: "true"`
```yaml
gcp-auth-skip-secret: "true"
```
To make the addon appear in `minikube addons list`, add it to `pkg/addons/config.go`. Here is the entry used by the `registry` addon, which will work for any addon which does not require custom code:
......
......@@ -22,7 +22,9 @@ Use Github's repositories and markdown editor as described by [Kubernetes's gene
To serve documentation pages locally, clone the `minikube` repository and run:
`make site`
```shell
make site
```
Notes :
......@@ -33,7 +35,9 @@ Notes :
We recommend installing [markdownlint](https://github.com/markdownlint/markdownlint) to find issues with your markdown file. Once installed, you can use this handy target:
`make mdlint`
```shell
make mdlint
```
## Style Guidelines
......
......@@ -12,7 +12,7 @@ You may need to add logs to the registry if the `TestJSONOutput` integration tes
### Background
minikube provides JSON output for `minikube start`, accesible via the `--output` flag:
```
```shell
minikube start --output json
```
......@@ -61,7 +61,7 @@ You will need to add your new log in two places:
Finally, set your new step in the cod by placing this line before you call `out.T`:
```
```go
register.Reg.SetStep(register.MyNewStep)
```
......
......@@ -30,4 +30,6 @@ The image is located at `gcr.io/k8s-minikube/gvisor-addon`
## Updating the gVisor image
`make push-gvisor-addon-image`
```shell
make push-gvisor-addon-image
```
......@@ -22,15 +22,18 @@ Alternatively, configure `sudo` to never prompt for the commands issued by minik
minikube's bootstrapper, [Kubeadm](https://github.com/kubernetes/kubeadm) verifies a list of features on the host system before installing Kubernetes. in case you get this error, and you still want to try minikube anyways despite your system's limitation you can skip the verification by starting minikube with this extra option:
`minikube start --extra-config kubeadm.ignore-preflight-errors=SystemVerification`
```shell
minikube start --extra-config kubeadm.ignore-preflight-errors=SystemVerification
```
## what is the resource allocation for Knative Setup using minikube?
Please allocate sufficient resources for Knative setup using minikube, especially when you run a minikube cluster on your local machine. We recommend allocating at least 6 CPUs and 8G memory.
`minikube start --cpus 6 --memory 8000`
```shell
minikube start --cpus 6 --memory 8000
```
## Do I need to install kubectl locally?
No, minikube comes with built-in kubectl [see minikube's kubectl documentation]({{< ref "docs/handbook/kubectl.md" >}}).
......@@ -24,7 +24,9 @@ A NodePort service is the most basic way to get external traffic directly to you
We also have a shortcut for fetching the minikube IP and a service's `NodePort`:
`minikube service --url $SERVICE`
```shell
minikube service --url $SERVICE
```
## Getting the NodePort using kubectl
......@@ -32,13 +34,17 @@ The minikube VM is exposed to the host system via a host-only IP address, that c
To determine the NodePort for your service, you can use a `kubectl` command like this (note that `nodePort` begins with lowercase `n` in JSON output):
`kubectl get service $SERVICE --output='jsonpath="{.spec.ports[0].nodePort}"'`
```shell
kubectl get service $SERVICE --output='jsonpath="{.spec.ports[0].nodePort}"'
```
### Increasing the NodePort range
By default, minikube only exposes ports 30000-32767. If this does not work for you, you can adjust the range by using:
`minikube start --extra-config=apiserver.service-node-port-range=1-65535`
```shell
minikube start --extra-config=apiserver.service-node-port-range=1-65535
```
This flag also accepts a comma separated list of ports and port ranges.
......@@ -57,7 +63,7 @@ Services of type `LoadBalancer` can be exposed via the `minikube tunnel` command
#### Run tunnel in a separate terminal
it will ask for password.
```
```shell
minikube tunnel
```
......@@ -88,16 +94,16 @@ Status:
#### Create a kubernetes deployment
```
```shell
kubectl create deployment hello-minikube1 --image=k8s.gcr.io/echoserver:1.4
```
#### Create a kubernetes service type LoadBalancer
```
```shell
kubectl expose deployment hello-minikube1 --type=LoadBalancer --port=8080
```
### Check external IP
```
```shell
kubectl get svc
```
<pre>
......
......@@ -8,8 +8,11 @@ date: 2020-07-15
If you have a containerized GCP app with a Kubernetes yaml, you can automatically add your credentials to all your deployed pods dynamically with this minikube addon. You just need to have a credentials file, which can be generated with `gcloud auth application-default login`. If you already have a json credentials file you want specify, use the GOOGLE_APPLICATION_CREDENTIALS environment variable.
- Start a cluster:
```
```shell
minikube start
```
```
😄 minikube v1.12.0 on Darwin 10.15.5
✨ Automatically selected the docker driver. Other choices: hyperkit, virtualbox
👍 Starting control plane node minikube in cluster minikube
......@@ -21,8 +24,11 @@ minikube start
```
- Enable the `gcp-auth` addon:
```
```shell
minikube addons enable gcp-auth
```
```
🔎 Verifying gcp-auth addon...
📌 Your GCP credentials will now be mounted into every pod created in the minikube cluster.
📌 If you don't want credential mounted into a specific pod, add a label with the `gcp-auth-skip-secret` key to your pod configuration.
......@@ -30,14 +36,17 @@ minikube addons enable gcp-auth
```
- For credentials in an arbitrary path:
```
```shell
export GOOGLE_APPLICATION_CREDENTIALS=<creds-path>.json
minikube addons enable gcp-auth
```
- Deploy your GCP app as normal:
```
```shell
kubectl apply -f test.yaml
```
```
deployment.apps/pytest created
```
......
......@@ -49,7 +49,9 @@ This flag is repeated, so you can pass it several times with several different v
By default, minikube installs the latest stable version of Kubernetes that was available at the time of the minikube release. You may select a different Kubernetes release by using the `--kubernetes-version` flag, for example:
`minikube start --kubernetes-version=v1.11.10`
```shell
minikube start --kubernetes-version=v1.11.10
```
minikube follows the [Kubernetes Version and Version Skew Support Policy](https://kubernetes.io/docs/setup/version-skew-policy/), so we guarantee support for the latest build for the last 3 minor Kubernetes releases. When practical, minikube aims to support older releases as well so that users can emulate legacy environments.
......
......@@ -10,40 +10,60 @@ aliases:
Start a cluster by running:
`minikube start`
```shell
minikube start
```
Access the Kubernetes Dashboard running within the minikube cluster:
`minikube dashboard`
```shell
minikube dashboard
```
Once started, you can interact with your cluster using `kubectl`, just like any other Kubernetes cluster. For instance, starting a server:
`kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.4`
```shell
kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.4
```
Exposing a service as a NodePort
`kubectl expose deployment hello-minikube --type=NodePort --port=8080`
```shell
kubectl expose deployment hello-minikube --type=NodePort --port=8080
```
minikube makes it easy to open this exposed endpoint in your browser:
`minikube service hello-minikube`
```shell
minikube service hello-minikube
```
Upgrade your cluster:
`minikube start --kubernetes-version=latest`
```shell
minikube start --kubernetes-version=latest
```
Start a second local cluster (_note: This will not work if minikube is using the bare-metal/none driver_):
`minikube start -p cluster2`
```shell
minikube start -p cluster2
```
Stop your local cluster:
`minikube stop`
```shell
minikube stop
```
Delete your local cluster:
`minikube delete`
```shell
minikube delete
```
Delete all local clusters and profiles
`minikube delete --all`
```shell
minikube delete --all
```
......@@ -10,7 +10,7 @@ aliases:
## kubectl
```
```shell
kubectl create deployment hello-minikube1 --image=k8s.gcr.io/echoserver:1.4
kubectl expose deployment hello-minikube1 --type=LoadBalancer --port=8080
```
......
......@@ -22,7 +22,7 @@ Place files to be synced in `$MINIKUBE_HOME/files`
For example, running the following will result in the deployment of a custom /etc/resolv.conf:
```
```shell
mkdir -p ~/.minikube/files/etc
echo nameserver 8.8.8.8 > ~/.minikube/files/etc/resolv.conf
minikube start
......
......@@ -12,29 +12,41 @@ inside minikube when the `minikube start` command is executed.
However if `kubectl` is not installed locally, minikube already includes kubectl which can be used like this:
`minikube kubectl -- <kubectl commands>`
```shell
minikube kubectl -- <kubectl commands>
```
You can also `alias kubectl="minikube kubectl --"` for easier usage.
Alternatively, you can create a symbolic link to minikube's binary named 'kubectl'.
`ln -s $(which minikube) /usr/local/bin/kubectl`
```shell
ln -s $(which minikube) /usr/local/bin/kubectl
```
Get pods
`minikube kubectl -- get pods`
```shell
minikube kubectl -- get pods
```
Creating a deployment inside kubernetes cluster
`minikube kubectl -- create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.4`
```shell
minikube kubectl -- create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.4
```
Exposing the deployment with a NodePort service
`minikube kubectl -- expose deployment hello-minikube --type=NodePort --port=8080`
```shell
minikube kubectl -- expose deployment hello-minikube --type=NodePort --port=8080
```
For more help
`minikube kubectl -- --help`
```shell
minikube kubectl -- --help
```
### Shell autocompletion
......
......@@ -14,13 +14,13 @@ aliases:
To mount a directory from the host into the guest using the `mount` subcommand:
```
```shell
minikube mount <source directory>:<target directory>
```
For example, this would mount your home directory to appear as /host within the minikube VM:
```
```shell
minikube mount $HOME:/host
```
......
......@@ -50,7 +50,7 @@ Quick guide for configuring minikube and docker on macOS, enabling docker to pus
The first step is to enable the registry addon:
```
```shell
minikube addons enable registry
```
......@@ -58,13 +58,13 @@ When enabled, the registry addon exposes its port 5000 on the minikube's virtual
In order to make docker accept pushing images to this registry, we have to redirect port 5000 on the docker virtual machine over to port 5000 on the minikube machine. We can (ab)use docker's network configuration to instantiate a container on the docker's host, and run socat there:
```
```shell
docker run --rm -it --network=host alpine ash -c "apk add socat && socat TCP-LISTEN:5000,reuseaddr,fork TCP:$(minikube ip):5000"
```
Once socat is running it's possible to push images to the minikube registry:
```
```shell
docker tag my/image localhost:5000/myimage
docker push localhost:5000/myimage
```
......@@ -77,7 +77,7 @@ Quick guide for configuring minikube and docker on Windows, enabling docker to p
The first step is to enable the registry addon:
```
```shell
minikube addons enable registry
```
......@@ -86,7 +86,7 @@ When enabled, the registry addon exposes its port 5000 on the minikube's virtual
In order to make docker accept pushing images to this registry, we have to redirect port 5000 on the docker virtual machine over to port 5000 on the minikube machine. Unfortunately, the docker vm cannot directly see the IP address of the minikube vm. To fix this, you will have to add one more level of redirection.
Use kubectl port-forward to map your local workstation to the minikube vm
```
```shell
kubectl port-forward --namespace kube-system <name of the registry vm> 5000:5000
```
......@@ -94,13 +94,13 @@ On your local machine you should now be able to reach the minikube registry by u
From this point we can (ab)use docker's network configuration to instantiate a container on the docker's host, and run socat there to redirect traffic going to the docker vm's port 5000 to port 5000 on your host workstation.
```
```shell
docker run --rm -it --network=host alpine ash -c "apk add socat && socat TCP-LISTEN:5000,reuseaddr,fork TCP:host.docker.internal:5000"
```
Once socat is running it's possible to push images to the minikube registry from your local workstation:
```
```shell
docker tag my/image localhost:5000/myimage
docker push localhost:5000/myimage
```
......
......@@ -21,7 +21,9 @@ Example:
minikube stores post-mortem INFO logs in the temporary directory of your system. On macOS or Linux, it's easy to get a list of recent INFO logs:
`find $TMPDIR -mtime -1 -type f -name "*minikube*INFO*" -ls 2>/dev/null`
```shell
find $TMPDIR -mtime -1 -type f -name "*minikube*INFO*" -ls 2>/dev/null
```
For instance, this shows:
......@@ -29,7 +31,9 @@ For instance, this shows:
These are plain text log files: you may rename them to "<filename>.log" and then drag/drop them into a GitHub issue for further analysis by the minikube team. You can quickly inspect the final lines of any of these logs via:
`tail -n 10 <filename>`
```shell
tail -n 10 <filename>
```
for example, this shows:
......@@ -83,4 +87,3 @@ minikube logs --problems
```
This will attempt to surface known errors, such as invalid configuration flags. If nothing interesting shows up, try `minikube logs`.
......@@ -17,7 +17,7 @@ You may install the Root Certificate into the minikube cluster to access these c
You will need a corporate X.509 Root Certificate in PEM format. If it's in DER format, convert it:
```
```shell
openssl x509 -inform der -in my_company.cer -out my_company.pem
```
......
......@@ -58,7 +58,7 @@ brew install minikube
If `which minikube` fails after installation via brew, you may have to remove the minikube cask and link the binary:
```
```shell
brew cask remove minikube
brew link minikube
```
......@@ -160,7 +160,9 @@ minikube tunnel
To find the routable IP, run this command and examine the `EXTERNAL-IP` column:
`kubectl get services balanced`
```shell
kubectl get services balanced
```
Your deployment is now available at &lt;EXTERNAL-IP&gt;:8080
......
......@@ -84,7 +84,10 @@ spec:
serviceName: hello-minikube
servicePort: 8080
```
Run the command: `kubectl apply -f hello-ingress.yaml`
Run the command:
```shell
kubectl apply -f hello-ingress.yaml
```
That's it! You can now access your service via Ambassador:
```shell script
......@@ -120,7 +123,10 @@ spec:
prefix: /hello-mapping/
service: mapping-minikube.default:8080
```
Run the command: `kubectl apply -f hello-mapping.yaml`
Run the command:
```shell
kubectl apply -f hello-mapping.yaml
```
That's it! You can now access your service via Ambassador:
```shell script
......
......@@ -17,8 +17,10 @@ date: 2019-11-24
## Tutorial
- Start a cluster with 2 nodes in the driver of your choice:
```
```shell
minikube start --nodes 2 -p multinode-demo
```
```
😄 [multinode-demo] minikube v1.10.1 on Darwin 10.15.4
✨ Automatically selected the hyperkit driver
👍 Starting control plane node multinode-demo in cluster multinode-demo
......@@ -40,16 +42,20 @@ To track progress on multi-node clusters, see https://github.com/kubernetes/mini
```
- Get the list of your nodes:
```
```shell
kubectl get nodes
```
```
NAME STATUS ROLES AGE VERSION
multinode-demo Ready master 72s v1.18.2
multinode-demo-m02 Ready <none> 33s v1.18.2
```
- You can also check the status of your nodes:
```shell
minikube status -p multinode-demo
```
```
$ minikube status -p multinode-demo
multinode-demo
type: Control Plane
host: Running
......@@ -64,33 +70,44 @@ kubelet: Running
```
- Deploy our hello world deployment:
```
```shell
kubectl apply -f hello-deployment.yaml
```
```
deployment.apps/hello created
```
```shell
kubectl rollout status deployment/hello
```
```
deployment "hello" successfully rolled out
```
- Deploy our hello world service, which just spits back the IP address the request was served from:
```
```shell
kubectl apply -f hello-svc.yaml
```
```
service/hello created
```
- Check out the IP addresses of our pods, to note for future reference
```
```shell
kubectl get pods -o wide
```
```
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
hello-c7b8df44f-qbhxh 1/1 Running 0 31s 10.244.0.3 multinode-demo <none> <none>
hello-c7b8df44f-xv4v6 1/1 Running 0 31s 10.244.0.2 multinode-demo <none> <none>
```
- Look at our service, to know what URL to hit
```
```shell
minikube service list -p multinode-demo
```
```
|-------------|------------|--------------|-----------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|-------------|------------|--------------|-----------------------------|
......@@ -101,8 +118,10 @@ minikube service list -p multinode-demo
```
- Let's hit the URL a few times and see what comes back
```
```shell
curl http://192.168.64.226:31000
```
```
Hello from hello-c7b8df44f-qbhxh (10.244.0.3)
curl http://192.168.64.226:31000
......
......@@ -14,7 +14,7 @@ Currently, minikube supports the following exporters for tracing data:
To collect trace data with minikube and the Stackdriver exporter, run:
```
```shell
MINIKUBE_GCP_PROJECT_ID=<project ID> minikube start --output json --trace gcp
```
......
......@@ -20,7 +20,9 @@ This tutorial explains how to start minikube with Pod Security Policies (PSP) en
Start minikube with the `PodSecurityPolicy` admission controller and the
`pod-security-policy` addon enabled.
`minikube start --extra-config=apiserver.enable-admission-plugins=PodSecurityPolicy --addons=pod-security-policy`
```shell
minikube start --extra-config=apiserver.enable-admission-plugins=PodSecurityPolicy --addons=pod-security-policy
```
The `pod-security-policy` addon must be enabled along with the admission
controller to prevent issues during bootstrap.
......@@ -35,12 +37,16 @@ the policies that addon enables must be separately applied to the cluster.
Before starting minikube, you need to give it the PSP YAMLs in order to allow minikube to bootstrap.
Create the directory:
`mkdir -p ~/.minikube/files/etc/kubernetes/addons`
```shell
mkdir -p ~/.minikube/files/etc/kubernetes/addons
```
Copy the YAML below into this file: `~/.minikube/files/etc/kubernetes/addons/psp.yaml`
Now start minikube:
`minikube start --extra-config=apiserver.enable-admission-plugins=PodSecurityPolicy`
```shell
minikube start --extra-config=apiserver.enable-admission-plugins=PodSecurityPolicy
```
```yaml
---
......@@ -191,7 +197,7 @@ Next, apply the YAML shown above to the cluster.
Finally, stop the cluster and then restart it with the admission controller
enabled.
```
```shell
minikube start
kubectl apply -f /path/to/psp.yaml
minikube stop
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册