From 9f0531ba75451a87f0350127d551906b16601a1f Mon Sep 17 00:00:00 2001 From: scotty Date: Fri, 18 Nov 2016 10:27:25 -0800 Subject: [PATCH 1/4] added "contribute to codebase" and "download k8s" buttons to the footer hide left nav area in docs if no nav is present update text link styles for better readability --- _includes/footer.html | 2 ++ _layouts/docwithnav.html | 27 +++++++++++++++++++++++++++ _sass/_base.sass | 19 +++++++++++++++++++ _sass/_reset.sass | 2 +- 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/_includes/footer.html b/_includes/footer.html index 15dacb72e0..e7fa36d26a 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -20,6 +20,8 @@ Events Calendar
+ Download K8s + Contribute to the K8s codebase
© {{ 'now' | date: "%Y" }} Kubernetes
diff --git a/_layouts/docwithnav.html b/_layouts/docwithnav.html index 8ca0906065..c15077857a 100755 --- a/_layouts/docwithnav.html +++ b/_layouts/docwithnav.html @@ -80,6 +80,33 @@ })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-36037335-10', 'auto'); ga('send', 'pageview'); + + // hide docs nav area if no nav is present + (function () { + window.addEventListener('DOMContentLoaded', init) + + // play nice with our neighbors + function init() { + window.removeEventListener('DOMContentLoaded', init) + hideNav() + } + + function hideNav(toc){ + if (!toc) toc = document.querySelector('#docsToc') + var container = toc.querySelector('.container') + + // container is built dynamically, so it may not be present on the first runloop + if (container) { + if (container.childElementCount === 0) { + document.getElementById('docsContent').style.width = '100%' + } + } else { + requestAnimationFrame(function () { + hideNav(toc) + }) + } + } + })(); diff --git a/_sass/_base.sass b/_sass/_base.sass index a8ac4b47c4..0feee846ff 100644 --- a/_sass/_base.sass +++ b/_sass/_base.sass @@ -389,6 +389,14 @@ footer display: block height: 0 overflow: hidden + + &.button + background-image: none + width: auto + height: auto + + &:hover + color: $blue a.twitter background-position: 0 0 @@ -874,8 +882,19 @@ dd img max-width: 100% + a + font-weight: 700 + text-decoration: underline + + a:visited + color: blueviolet + a.button border-radius: 2px + text-decoration: none + + &:visited + color: white a.issue margin-left: 20px diff --git a/_sass/_reset.sass b/_sass/_reset.sass index 9f4a43a68e..2a8bb1b6d2 100755 --- a/_sass/_reset.sass +++ b/_sass/_reset.sass @@ -15,7 +15,7 @@ ul, li ul margin: 0 padding: 0 - + a text-decoration: none From 88e32adc986da0cf4263aa2b670ac640febe0ed3 Mon Sep 17 00:00:00 2001 From: steveperry-53 Date: Thu, 17 Nov 2016 17:07:34 -0800 Subject: [PATCH 2/4] Write new task: Determining the Reason for Pod Failure. --- _data/tasks.yml | 8 ++ .../determine-reason-pod-failure.md | 110 ++++++++++++++++++ .../termination.yaml | 10 ++ 3 files changed, 128 insertions(+) create mode 100644 docs/tasks/debug-application-cluster/determine-reason-pod-failure.md create mode 100644 docs/tasks/debug-application-cluster/termination.yaml diff --git a/_data/tasks.yml b/_data/tasks.yml index 4c6cd1b709..9898fae32f 100644 --- a/_data/tasks.yml +++ b/_data/tasks.yml @@ -15,6 +15,14 @@ toc: section: - title: Using Port Forwarding to Access Applications in a Cluster path: /docs/tasks/access-application-cluster/port-forward-access-application-cluster/ + + +- title: Debugging Applications in a Cluster + section: + - title: Determining the Reason for Pod Failure + path: /docs/tasks/debug-application-cluster/determine-reason-pod-failure/ + + - title: Accessing the Kubernetes API section: - title: Using an HTTP Proxy to Access the Kubernetes API diff --git a/docs/tasks/debug-application-cluster/determine-reason-pod-failure.md b/docs/tasks/debug-application-cluster/determine-reason-pod-failure.md new file mode 100644 index 0000000000..f0f611e235 --- /dev/null +++ b/docs/tasks/debug-application-cluster/determine-reason-pod-failure.md @@ -0,0 +1,110 @@ +--- +--- + +{% capture overview %} + +This page shows how to write and read a Container +termination message. + +Termination messages provide a way for containers to write +information about fatal events to a location where it can +be easily retrieved and surfaced by tools like dashboards +and monitoring software. In most cases, information that you +put in a termination message should also be written to +the general +[Kubernetes logs](/docs/user-guide/logging/). + +{% endcapture %} + + +{% capture prerequisites %} + +{% include task-tutorial-prereqs.md %} + +{% endcapture %} + + +{% capture steps %} + +### Writing and reading a termination message + +In this exercise, you create a Pod that runs one container. +The configuration file specifies a command that runs when +the container starts. + +{% include code.html language="yaml" file="termination.yaml" ghlink="/docs/tasks/debug-pod-container/termination.yaml" %} + +1. Create a Pod based on the YAML configuration file: + + export REPO=https://raw.githubusercontent.com/kubernetes/kubernetes.github.io/master + kubectl create -f $REPO/docs/tasks/debug-pod-container/termination.yaml + + In the YAML file, in the `cmd` and `args` fields, you can see that the + container sleeps for 10 seconds and then writes "Sleep expired" to + the `/dev/termination-log` file. After the container writes + the "Sleep expired" message, it terminates. + +1. Display information about the Pod: + + kubectl get pod termination-demo + + Repeat the preceding command until the Pod is no longer running. + +1. Display detailed information about the Pod: + + kubectl get pod --output=yaml + + The output includes the "Sleep expired" message: + + apiVersion: v1 + kind: Pod + ... + lastState: + terminated: + containerID: ... + exitCode: 0 + finishedAt: ... + message: | + Sleep expired + ... + +1. Use a Go template to filter the output so that it includes +only the termination message: + +``` +{% raw %} kubectl get pod termination-demo -o go-template="{{range .status.containerStatuses}}{{.lastState.terminated.message}}{{end}}"{% endraw %} +``` + +### Setting the termination log file + +By default Kubernetes retrieves termination messages from +`/dev/termination-log`. To change this to a different file, +specify a `terminationMessagePath` field for your Container. + +For example, suppose your Container writes termination messages to +`/tmp/my-log`, and you want Kubernetes to retrieve those messages. +Set `terminationMessagePath` as shown here: + + apiVersion: v1 + kind: Pod + metadata: + name: msg-path-demo + spec: + containers: + - name: msg-path-demo-container + image: debian + terminationMessagePath: "/tmp/my-log" + +{% endcapture %} + +{% capture whatsnext %} + +* See the `terminationMessagePath` field in + [Container](/docs/api-reference/v1/definitions#_v1_container). +* Learn about [retrieving logs](/docs/user-guide/logging/). +* Learn about [Go templates](https://golang.org/pkg/text/template/). + +{% endcapture %} + + +{% include templates/task.md %} diff --git a/docs/tasks/debug-application-cluster/termination.yaml b/docs/tasks/debug-application-cluster/termination.yaml new file mode 100644 index 0000000000..3f63748f72 --- /dev/null +++ b/docs/tasks/debug-application-cluster/termination.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Pod +metadata: + name: termination-demo +spec: + containers: + - name: termination-demo-container + image: debian + command: ["/bin/sh"] + args: ["-c", "sleep 10 && echo Sleep expired > /dev/termination-log"] From 39d1962b287b0636748c695f5199ebbbf625d20b Mon Sep 17 00:00:00 2001 From: scotty Date: Fri, 18 Nov 2016 12:09:19 -0800 Subject: [PATCH 3/4] unbold a tags in #docsContent --- _sass/_base.sass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_sass/_base.sass b/_sass/_base.sass index 0feee846ff..1eabc9ac14 100644 --- a/_sass/_base.sass +++ b/_sass/_base.sass @@ -883,7 +883,7 @@ dd max-width: 100% a - font-weight: 700 + //font-weight: 700 text-decoration: underline a:visited From 81b7f61c3b5d70a976574865014ba4eff3aaaffb Mon Sep 17 00:00:00 2001 From: scotty Date: Fri, 18 Nov 2016 12:56:07 -0800 Subject: [PATCH 4/4] disable TOC if there's only a link to the current page --- _layouts/docwithnav.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/_layouts/docwithnav.html b/_layouts/docwithnav.html index c15077857a..f3d885d246 100755 --- a/_layouts/docwithnav.html +++ b/_layouts/docwithnav.html @@ -81,7 +81,7 @@ ga('create', 'UA-36037335-10', 'auto'); ga('send', 'pageview'); - // hide docs nav area if no nav is present + // hide docs nav area if no nav is present, or if nav only contains a link to the current page (function () { window.addEventListener('DOMContentLoaded', init) @@ -97,7 +97,8 @@ // container is built dynamically, so it may not be present on the first runloop if (container) { - if (container.childElementCount === 0) { + if (container.childElementCount === 0 || toc.querySelectorAll('a.item').length === 1) { + toc.style.display = 'none' document.getElementById('docsContent').style.width = '100%' } } else {