update istioctl docs auto-generation script (#79)

* update istioctl docs auto-generation script

* istioctl: fix example usage formatting
This commit is contained in:
Jason Young 2017-04-28 13:32:33 -07:00 committed by Martin Taillefer
parent 85bd965c56
commit 98f1d119a4
17 changed files with 245 additions and 312 deletions

View File

@ -1,12 +0,0 @@
---
title: The Istioctl Command - Take 2
overview: Explains the various features and options of the istioctl command.
order: 11
bodyclass: docs
layout: docs
type: markdown
---
{% include section-index.html %}

View File

@ -1,62 +0,0 @@
---
title: Inject istio sidecar proxy into kubernetes resources
overview: Inject istio sidecar proxy into kubernetes resources
order: 60
bodyclass: docs
layout: docs
type: markdown
---
## istioctl kube-inject
Inject istio sidecar proxy into kubernetes resources
### Synopsis
Use kube-inject to manually inject istio sidecar proxy into kubernetes
resource files. Unsupported resources are left unmodified so it is
safe to run kube-inject over a single file that contains multiple
Service, ConfigMap, Deployment, etc. definitions for a complex
application. Its best to do this when the resource is initially
created.
Example usage:
kubectl apply -f <(istioctl kube-inject -f <resource.yaml>)
```
istioctl kube-inject
```
### Options
```
--coreDump Enable/Disable core dumps in injected proxy (--coreDump=true affects all pods in a node and should only be used the cluster admin) (default true)
-f, --filename string Input kubernetes resource filename
--hub string Docker hub
--includeIPRanges string Comma separated list of IP ranges in CIDR form. If set, only redirect outbound traffic to Envoy for IP ranges. Otherwise all outbound traffic is redirected
--meshConfig string ConfigMap name for Istio mesh configuration, key should be "mesh" (default "istio")
-o, --output string Modified output kubernetes resource filename
--setVersionString string Override version info injected into resource
--sidecarProxyUID int Sidecar proxy UID (default 1337)
--tag string Docker tag
--verbosity int Runtime verbosity (default 2)
```
### Options inherited from parent commands
```
-c, --kubeconfig string Use a Kubernetes configuration file instead of in-cluster configuration
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
-n, --namespace string Select a Kubernetes namespace (default "default")
-v, --v Level log level for V logs
--vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging
```
### SEE ALSO
* [istioctl](istioctl.html) - Istio control interface

View File

@ -1,139 +0,0 @@
---
title: The istioctl Command
overview: Describes the usage and options of the istioctl command-line tool.
order: 10
bodyclass: docs
layout: docs
type: markdown
---
**istioctl** is a command line interface for managing an Istio service mesh. This overview covers
syntax, describes command operations, and provides examples.
# Syntax
*istioctl* commands follow the syntax:
```shell
istioctl <command> [targets] [flags]
```
where *command*, *targets* and *flags* are:
* **command**: the operation to perform, such as `create`, `delete`, `replace`, or `get`.
* **targets**: targets for commands such as delete
* **flags**: Optional flags. For example specify `--file FILENAME` to specify a configuration file to create from.
# Operations
* **create**: Create policies and rules
* **delete**: Delete policies or rules
* **get**: Retrieve policy/policies or rules
* **replace**: Replace policies and rules
* **version**: Display CLI version information
_Kubernetes specific_
* **kube-inject**: Inject Envoy proxy into Kubernetes Pods
resources. This command has been added to aid in *istiofying*
services for Kubernetes and should eventually go away once a proper
Istio admission controller for Kubernetes is available.
# Policy and Rule types
* **route-rule** Describes a rule for routing network traffic. See [Route Rules](/docs/reference/routing-and-traffic-management.html#route-rules) for details on routing rules.
* **destination-policy** Describes a policy for traffic destinations. See [Destination Policies](/docs/reference/routing-and-traffic-management.html#destination-policies) for details on destination policies.
# Examples of common operations
`istioctl create [--file FILE]` - Create policies or rules from a file or stdin.
```shell
# Create a rule using the definition in example-routing.yaml.
$ istioctl create -f example-routing.yaml
```
`istioctl delete [TYPE NAME_1 ... NAME_N] [--file FILE]` - Create policies or rules from a file or stdin.
```shell
# Delete a rule using the definition in example-routing.yaml.
$ istioctl delete -f example-routing.yaml
```
```shell
# Delete the rule productpage-default
$ istioctl delete route-rule productpage-default
```
`istioctl get TYPE [NAME] [--output yaml|short]` - List policies or rules in YAML format
```shell
# List route rules
istioctl get route-rules
# List destination policies
istioctl get destination-policies
# Get the rule productpage-default
istioctl get route-rule productpage-default
```
`istioctl replace [--file FILENAME]` - Replace existing policies or rules with another from a file or stdin.
```shell
# Create a rule using the definition in example-routing.yaml.
$ istioctl replace -f example-routing.yaml
```
# kube-inject
`istioctl kube-inject [--filename FILENAME] [--hub HUB] [--meshConfig CONFIGMAP_NAME] [--output FILENAME] [--setVersionString VERSION] [--sidecarProxyUID UID] [--tag TAG] [--verbosity VERBOSITY]` - add Istio components to description
A short term workaround for the lack of a proper istio admision
controller is client-side injection. Use `istioctl kube-inject` to add the
necessary configurations to a Kubernetes resource files.
istioctl kube-inject -f deployment.yaml -o deployment-with-istio.yaml
Or update the resource on the fly before applying.
kubectl create -f <(istioctl kube-inject -f depoyment.yaml)
Or update an existing deployment.
kubectl get deployment -o yaml | istioctl kube-inject -f - | kubectl apply -f -
`istioctl kube-inject` will update
the [PodTemplateSpec](https://kubernetes.io/docs/concepts/workloads/pods/pod-overview/#pod-templates) in
Kubernetes Job, DaemonSet, ReplicaSet, and Deployment YAML resource
documents. Support for additional pod-based resource types can be
added as necessary.
Unsupported resources are left unmodified so, for example, it is safe
to run `istioctl kube-inject` over a single file that contains multiple
Service, ConfigMap, and Deployment definitions for a complex
application.
The Istio project is continually evolving so the low-level proxy
configuration may change unannounced. When in doubt re-run `istioctl kube-inject`
on your original deployments.
## kube-inject flags
* `--coreDump` - Enable/Disable core dumps in injected proxy (--coreDump=true affects all pods in a node and should only be used the cluster admin) (default true)
* `--filename FILENAME` - Input kubernetes resource filename
* `--hub HUB` - Docker hub, for example docker.io/istio)
* `--meshConfig CONFIGMAP_NAME` - ConfigMap name for Istio mesh configuration, key should be "mesh" (default "istio")
* `--output FILENAME` - Modified output kubernetes resource filename
* `--setVersionString VERSION` - Override version info injected into resource
* `--sidecarProxyUID UID` - Sidecar proxy UID (default 1337)
* `--tag TAG` - Docker image file tag
* `--verbosity VERBOSITY` - Runtime verbosity (default 2)
# General command line flags
* `--kubeconfig FILENAME` - Use a Kubernetes configuration file instead of in-cluster configuration. (default _~/.kube/config_)
* `--namespace NAMESPACE` - Kubernetes namespace (default "default")
* `--v LEVEL` - log level for V logs
* `--vmodule MODULESPEC` - comma-separated list of pattern=N settings for file-filtered logging

View File

@ -0,0 +1,9 @@
---
title: The Istioctl Command
overview: Options showing how to use the istioctl command.
order: 0
bodyclass: docs
layout: docs
type: markdown
---
{% include section-index.html %}

View File

@ -1,9 +1,7 @@
---
title: Istioctl Control
title: istioctl
overview: Istio control interface
order: 200
order: 6
bodyclass: docs
layout: docs
type: markdown
@ -15,7 +13,18 @@ Istio control interface
### Synopsis
Istio configuration command line utility. Available configuration types: [destination-policy ingress-rule route-rule]
Istio configuration command line utility.
Create, list, modify, and delete configuration resources in the Istio system.
Available routing and traffic management configuration types: [destination-policy ingress-rule route-rule]. See
https://istio.io/docs/reference/routing-and-traffic-management.html
for an overview of the routing and traffic DSL.
More information on the mixer API configuration can be found under the
istioctl mixer command documentation.
### Options
@ -31,8 +40,9 @@ Istio configuration command line utility. Available configuration types: [destin
* [istioctl completion](istioctl_completion.html) - Generate bash completion for Istioctl
* [istioctl create](istioctl_create.html) - Create policies and rules
* [istioctl delete](istioctl_delete.html) - Delete policies or rules
* [istioctl get](istioctl_get.html) - Retrieve a policy or rule
* [istioctl kube-inject](istioctl_kube-inject.html) - Inject istio sidecar proxy into kubernetes resources
* [istioctl get](istioctl_get.html) - Retrieve policies and rules
* [istioctl kube-inject](istioctl_kube-inject.html) - Inject Envoy sidecar into Kubernetes pod resources
* [istioctl mixer](istioctl_mixer.html) - Istio Mixer configuration
* [istioctl replace](istioctl_replace.html) - Replace policies and rules
* [istioctl replace](istioctl_replace.html) - Replace existing policies and rules
* [istioctl version](istioctl_version.html) - Display version information and exit

View File

@ -1,9 +1,7 @@
---
title: Generate bash completion for Istioctl
title: istioctl completion
overview: Generate bash completion for Istioctl
order: 200
order: 1
bodyclass: docs
layout: docs
type: markdown
@ -17,7 +15,7 @@ Generate bash completion for Istioctl
Output shell completion code for the bash shell. The shell output must
be evaluated for to provide interactive completion of istioctl
be evaluated to provide interactive completion of istioctl
commands.
Examples:

View File

@ -1,9 +1,7 @@
---
title: Create policies and rules
title: istioctl create
overview: Create policies and rules
order: 20
order: 2
bodyclass: docs
layout: docs
type: markdown
@ -15,7 +13,12 @@ Create policies and rules
### Synopsis
Create policies and rules
Example usage:
# Create a rule using the definition in example-routing.yaml.
$ istioctl create -f example-routing.yaml
```
istioctl create

View File

@ -1,9 +1,7 @@
---
title: Delete policies or rules
title: istioctl delete
overview: Delete policies or rules
order: 30
order: 3
bodyclass: docs
layout: docs
type: markdown
@ -15,10 +13,18 @@ Delete policies or rules
### Synopsis
Delete policies or rules
Example usage:
# Delete a rule using the definition in example-routing.yaml.
$ istioctl delete -f example-routing.yaml
# Delete the rule productpage-default
$ istioctl delete route-rule productpage-default
```
istioctl delete <type> <name> [<name2> ... <nameN>]
istioctl delete
```
### Options

View File

@ -1,24 +1,33 @@
---
title: Retrieve a policy or rule
overview: Retrieve a policy or rule
order: 40
title: istioctl get
overview: Retrieve policies and rules
order: 4
bodyclass: docs
layout: docs
type: markdown
---
## istioctl get
Retrieve a policy or rule
Retrieve policies and rules
### Synopsis
Retrieve a policy or rule
Example usage:
# List all route rules
istioctl get route-rules
# List all destination policies
istioctl get destination-policies
# Get a specific rule named productpage-default
istioctl get route-rule productpage-default
```
istioctl get <type> <name>
istioctl get
```
### Options

View File

@ -0,0 +1,81 @@
---
title: istioctl kube-inject
overview: Inject Envoy sidecar into Kubernetes pod resources
order: 5
bodyclass: docs
layout: docs
type: markdown
---
## istioctl kube-inject
Inject Envoy sidecar into Kubernetes pod resources
### Synopsis
Automatic Envoy sidecar injection via k8s admission controller is not
ready yet. Instead, use kube-inject to manually inject Envoy sidecar
into Kubernetes resource files. Unsupported resources are left
unmodified so it is safe to run kube-inject over a single file that
contains multiple Service, ConfigMap, Deployment, etc. definitions for
a complex application. Its best to do this when the resource is
initially created.
k8s.io/docs/concepts/workloads/pods/pod-overview/#pod-templates is
updated for Job, DaemonSet, ReplicaSet, and Deployment YAML resource
documents. Support for additional pod-based resource types can be
added as necessary.
The Istio project is continually evolving so the Istio sidecar
configuration may change unannounced. When in doubt re-run istioctl
kube-inject on deployments to get the most up-to-date changes.
Example usage:
# Update resources on the fly before applying.
kubectl apply -f <(istioctl kube-inject -f <resource.yaml>)
# Create a persistent version of the deployment with Envoy sidecar
# injected. This is particularly useful to understand what is
# being injected before committing to Kubernetes API server.
istioctl kube-inject -f deployment.yaml -o deployment-with-istio.yaml
# Update an existing deployment.
kubectl get deployment -o yaml | istioctl kube-inject -f - | kubectl apply -f -
```
istioctl kube-inject
```
### Options
```
--coreDump Enable/Disable core dumps in injected Envoy sidecar (--coreDump=true affects all pods in a node and should only be used the cluster admin) (default true)
-f, --filename string Input Kubernetes resource filename
--hub string Docker hub
--includeIPRanges string Comma separated list of IP ranges in CIDR form. If set, only redirect outbound traffic to Envoy for IP ranges. Otherwise all outbound traffic is redirected
--meshConfig string ConfigMap name for Istio mesh configuration, key should be "mesh" (default "istio")
-o, --output string Modified output Kubernetes resource filename
--setVersionString string Override version info injected into resource
--sidecarProxyUID int Envoy sidecar UID (default 1337)
--tag string Docker tag
--verbosity int Runtime verbosity (default 2)
```
### Options inherited from parent commands
```
-c, --kubeconfig string Use a Kubernetes configuration file instead of in-cluster configuration
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
-n, --namespace string Select a Kubernetes namespace (default "default")
-v, --v Level log level for V logs
--vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging
```
### SEE ALSO
* [istioctl](istioctl.html) - Istio control interface

View File

@ -1,9 +1,7 @@
---
title: Istio Mixer configuration
title: istioctl mixer
overview: Istio Mixer configuration
order: 100
order: 7
bodyclass: docs
layout: docs
type: markdown
@ -15,12 +13,28 @@ Istio Mixer configuration
### Synopsis
Istio Mixer configuration
The Mixer configuration API allows users to configure all facets of the
Mixer.
See https://istio.io/docs/concepts/policy-and-control/mixer-config.html
for a description of Mixer configuration's scope, subject, and rules.
Example usage:
# The Mixer config server can be accessed from outside the
# Kubernetes cluster using port forwarding.
CONFIG_PORT=$(kubectl get pod -l istio=mixer \
-o jsonpath='{.items[0].spec.containers[0].ports[1].containerPort}')
export ISTIO_MIXER_API_SERVER=localhost:${CONFIG_PORT}
kubectl port-forward $(kubectl get pod -l istio=mixer \
-o jsonpath='{.items[0].metadata.name}') ${CONFIG_PORT}:${CONFIG_PORT} &
### Options
```
-m, --mixer string Address of the mixer API server as <host>:<port>
-m, --mixer string Address of the Mixer configuration server as <host>:<port>
```
### Options inherited from parent commands

View File

@ -1,9 +1,7 @@
---
title: Istio Mixer Rule configuration
title: istioctl mixer rule
overview: Istio Mixer Rule configuration
order: 110
order: 10
bodyclass: docs
layout: docs
type: markdown
@ -15,14 +13,16 @@ Istio Mixer Rule configuration
### Synopsis
Istio Mixer Rule configuration
Create and list Mixer rules in the configuration server.
### Options inherited from parent commands
```
-c, --kubeconfig string Use a Kubernetes configuration file instead of in-cluster configuration
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
-m, --mixer string Address of the mixer API server as <host>:<port>
-m, --mixer string Address of the Mixer configuration server as <host>:<port>
-n, --namespace string Select a Kubernetes namespace (default "default")
-v, --v Level log level for V logs
--vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging

View File

@ -1,9 +1,7 @@
---
title: Create Istio Mixer rules
title: istioctl mixer rule create
overview: Create Istio Mixer rules
order: 120
order: 8
bodyclass: docs
layout: docs
type: markdown
@ -15,16 +13,21 @@ Create Istio Mixer rules
### Synopsis
Create Istio Mixer rules
Example usage:
# Create a new Mixer rule for the given scope and subject.
istioctl mixer rule create global myservice.ns.svc.cluster.local -f mixer-rule.yml
```
istioctl mixer rule create <scope> <subject>
istioctl mixer rule create
```
### Options
```
-f, --file string Input file with contents of the mixer rule
-f, --file string Input file with contents of the Mixer rule
```
### Options inherited from parent commands
@ -32,7 +35,7 @@ istioctl mixer rule create <scope> <subject>
```
-c, --kubeconfig string Use a Kubernetes configuration file instead of in-cluster configuration
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
-m, --mixer string Address of the mixer API server as <host>:<port>
-m, --mixer string Address of the Mixer configuration server as <host>:<port>
-n, --namespace string Select a Kubernetes namespace (default "default")
-v, --v Level log level for V logs
--vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging

View File

@ -1,9 +1,7 @@
---
title: Get Istio Mixer rules
title: istioctl mixer rule get
overview: Get Istio Mixer rules
order: 130
order: 9
bodyclass: docs
layout: docs
type: markdown
@ -15,10 +13,17 @@ Get Istio Mixer rules
### Synopsis
Get Istio Mixer rules
Get a Mixer rule for a given scope and subject.
Example usage:
# Get the Mixer rule with scope='global' and subject='myservice.ns.svc.cluster.local'
istioctl mixer rule get global myservice.ns.svc.cluster.local
```
istioctl mixer rule get <scope> <subject>
istioctl mixer rule get
```
### Options inherited from parent commands
@ -26,7 +31,7 @@ istioctl mixer rule get <scope> <subject>
```
-c, --kubeconfig string Use a Kubernetes configuration file instead of in-cluster configuration
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
-m, --mixer string Address of the mixer API server as <host>:<port>
-m, --mixer string Address of the Mixer configuration server as <host>:<port>
-n, --namespace string Select a Kubernetes namespace (default "default")
-v, --v Level log level for V logs
--vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging

View File

@ -1,21 +1,24 @@
---
title: Replace policies and rules
overview: Replace policies and rules
order: 50
title: istioctl replace
overview: Replace existing policies and rules
order: 11
bodyclass: docs
layout: docs
type: markdown
---
## istioctl replace
Replace policies and rules
Replace existing policies and rules
### Synopsis
Replace policies and rules
Example usage:
# Create a rule using the definition in example-routing.yaml.
$ istioctl replace -f example-routing.yaml
```
istioctl replace

View File

@ -1,9 +1,7 @@
---
title: Display version information and exit
overview: Display version information and exit.
order: 200
title: istioctl version
overview: Display version information and exit
order: 12
bodyclass: docs
layout: docs
type: markdown

View File

@ -6,29 +6,17 @@ set -o pipefail
BASE=$(cd "$(dirname "$0")" ; pwd -P)/..
ISTIOCTL=${ISTIOCTL:-istioctl}
ISTIOCTL_DIR=$(readlink -f ${BASE}/_docs/reference/istioctl-autogen/)
function mainPageHeader() {
cat <<EOF
---
category: Reference
title: Istioctl
overview: ${title}
bodyclass: docs
layout: docs
type: markdown
---
EOF
}
ISTIOCTL_DIR=$(readlink -f ${BASE}/_docs/reference/istioctl/)
function commandHeader() {
title=${1}
overview=${2}
order=${3}
cat <<EOF
---
category: Reference
title: ${title}
overview: ${title}
parent: Istioctl
overview: ${overview}
order: ${order}
bodyclass: docs
layout: docs
type: markdown
@ -36,28 +24,47 @@ type: markdown
EOF
}
# Generate markdown files with istioctl.
function generateIndex() {
order=${1}
cat <<EOF
---
title: The Istioctl Command
overview: Options showing how to use the istioctl command.
order: ${order}
bodyclass: docs
layout: docs
type: markdown
---
{% include section-index.html %}
EOF
}
# Generate raw markdown files with istioctl markdown.
rm ${ISTIOCTL_DIR}/* || echo "nothing to clean from ${ISTIOCTL_DIR}/"
mkdir -p ${ISTIOCTL_DIR}
rm ${ISTIOCTL_DIR}/*
${ISTIOCTL} markdown --dir ${ISTIOCTL_DIR}
order=0
# Patch markdown up with the proper formatting.
for file in ${ISTIOCTL_DIR}/*.md; do
# Use the first header line as the title.
title=$(sed -n '/^[^#]/ {p;q;}' ${file})
title=$(grep -m1 -oP '^## \K.*' ${file})
# Use non-comment line as the overview
overview=$(grep -m1 -oP '\K^\w.*' ${file})
# Arrange pages based on 'ls' alphabetical ordering.
order=$((${order} + 1))
# Prepend template header.
out=$(mktemp)
case ${file} in
${ISTIOCTL_DIR}/istioctl.md)
mainPageHeader "${title}" | cat - ${file} > ${out}
;;
*)
commandHeader "${title}" | cat - ${file} > ${out}
;;
esac
commandHeader "${title}" "${overview}" "${order}"| cat - ${file} > ${out}
cp ${out} ${file}
# Rename markdown links to html equivalent.
sed -i 's|\(\[.*\]\)(\(.*\).md)|\1(\2.html)|' ${file}
done
# Generate main index last so it isn't patched by previous steps.
generateIndex 0 > ${ISTIOCTL_DIR}/index.md