From 462f4553e24aee235c6b47de9238b8380bd7666a Mon Sep 17 00:00:00 2001 From: June Yi Date: Sun, 14 Oct 2018 20:58:41 +0900 Subject: [PATCH] Fix build failure by adding example and include files (#10610) Signed-off-by: June Yi --- content/zh/docs/reference/tools.md | 3 - .../examples/application/job/redis/job.yaml | 14 ++++ .../examples/application/job/redis/worker.py | 23 +++++++ content/zh/examples/audit/audit-policy.yaml | 68 +++++++++++++++++++ content/zh/examples/pods/pod-nginx.yaml | 13 ++++ content/zh/includes/task-tutorial-prereqs.md | 8 +++ .../zh/includes/user-guide-content-moved.md | 0 7 files changed, 126 insertions(+), 3 deletions(-) create mode 100644 content/zh/examples/application/job/redis/job.yaml create mode 100644 content/zh/examples/application/job/redis/worker.py create mode 100644 content/zh/examples/audit/audit-policy.yaml create mode 100644 content/zh/examples/pods/pod-nginx.yaml create mode 100644 content/zh/includes/task-tutorial-prereqs.md create mode 100644 content/zh/includes/user-guide-content-moved.md diff --git a/content/zh/docs/reference/tools.md b/content/zh/docs/reference/tools.md index 565d94b2fe..4fa74d6821 100644 --- a/content/zh/docs/reference/tools.md +++ b/content/zh/docs/reference/tools.md @@ -14,9 +14,7 @@ content_template: templates/concept --- {{% capture overview %}} Kubernetes 包含一些内置工具,可以帮助用户更好的使用 Kubernetes 系统。 @@ -102,7 +100,6 @@ Use Kompose to: * Translate a Docker Compose file into Kubernetes objects * Go from local Docker development to managing your application via Kubernetes * Convert v1 or v2 Docker Compose `yaml` files or [Distributed Application Bundles](https://docs.docker.com/compose/bundles/) -{{% /capture %}} --> 使用 Kompose: diff --git a/content/zh/examples/application/job/redis/job.yaml b/content/zh/examples/application/job/redis/job.yaml new file mode 100644 index 0000000000..ee7a06c732 --- /dev/null +++ b/content/zh/examples/application/job/redis/job.yaml @@ -0,0 +1,14 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: job-wq-2 +spec: + parallelism: 2 + template: + metadata: + name: job-wq-2 + spec: + containers: + - name: c + image: gcr.io/myproject/job-wq-2 + restartPolicy: OnFailure diff --git a/content/zh/examples/application/job/redis/worker.py b/content/zh/examples/application/job/redis/worker.py new file mode 100644 index 0000000000..49e5dae798 --- /dev/null +++ b/content/zh/examples/application/job/redis/worker.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +import time +import rediswq + +host="redis" +# Uncomment next two lines if you do not have Kube-DNS working. +# import os +# host = os.getenv("REDIS_SERVICE_HOST") + +q = rediswq.RedisWQ(name="job2", host="redis") +print("Worker with sessionID: " + q.sessionID()) +print("Initial queue state: empty=" + str(q.empty())) +while not q.empty(): + item = q.lease(lease_secs=10, block=True, timeout=2) + if item is not None: + itemstr = item.decode("utf=8") + print("Working on " + itemstr) + time.sleep(10) # Put your actual work here instead of sleep. + q.complete(item) + else: + print("Waiting for work") +print("Queue empty, exiting") diff --git a/content/zh/examples/audit/audit-policy.yaml b/content/zh/examples/audit/audit-policy.yaml new file mode 100644 index 0000000000..b5d66b3a18 --- /dev/null +++ b/content/zh/examples/audit/audit-policy.yaml @@ -0,0 +1,68 @@ +apiVersion: audit.k8s.io/v1beta1 # This is required. +kind: Policy +# Don't generate audit events for all requests in RequestReceived stage. +omitStages: + - "RequestReceived" +rules: + # Log pod changes at RequestResponse level + - level: RequestResponse + resources: + - group: "" + # Resource "pods" doesn't match requests to any subresource of pods, + # which is consistent with the RBAC policy. + resources: ["pods"] + # Log "pods/log", "pods/status" at Metadata level + - level: Metadata + resources: + - group: "" + resources: ["pods/log", "pods/status"] + + # Don't log requests to a configmap called "controller-leader" + - level: None + resources: + - group: "" + resources: ["configmaps"] + resourceNames: ["controller-leader"] + + # Don't log watch requests by the "system:kube-proxy" on endpoints or services + - level: None + users: ["system:kube-proxy"] + verbs: ["watch"] + resources: + - group: "" # core API group + resources: ["endpoints", "services"] + + # Don't log authenticated requests to certain non-resource URL paths. + - level: None + userGroups: ["system:authenticated"] + nonResourceURLs: + - "/api*" # Wildcard matching. + - "/version" + + # Log the request body of configmap changes in kube-system. + - level: Request + resources: + - group: "" # core API group + resources: ["configmaps"] + # This rule only applies to resources in the "kube-system" namespace. + # The empty string "" can be used to select non-namespaced resources. + namespaces: ["kube-system"] + + # Log configmap and secret changes in all other namespaces at the Metadata level. + - level: Metadata + resources: + - group: "" # core API group + resources: ["secrets", "configmaps"] + + # Log all other resources in core and extensions at the Request level. + - level: Request + resources: + - group: "" # core API group + - group: "extensions" # Version of group should NOT be included. + + # A catch-all rule to log all other requests at the Metadata level. + - level: Metadata + # Long-running requests like watches that fall under this rule will not + # generate an audit event in RequestReceived. + omitStages: + - "RequestReceived" \ No newline at end of file diff --git a/content/zh/examples/pods/pod-nginx.yaml b/content/zh/examples/pods/pod-nginx.yaml new file mode 100644 index 0000000000..134ddae2aa --- /dev/null +++ b/content/zh/examples/pods/pod-nginx.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Pod +metadata: + name: nginx + labels: + env: test +spec: + containers: + - name: nginx + image: nginx + imagePullPolicy: IfNotPresent + nodeSelector: + disktype: ssd diff --git a/content/zh/includes/task-tutorial-prereqs.md b/content/zh/includes/task-tutorial-prereqs.md new file mode 100644 index 0000000000..6f1407fe45 --- /dev/null +++ b/content/zh/includes/task-tutorial-prereqs.md @@ -0,0 +1,8 @@ +You need to have a Kubernetes cluster, and the kubectl command-line tool must +be configured to communicate with your cluster. If you do not already have a +cluster, you can create one by using +[Minikube](/docs/getting-started-guides/minikube), +or you can use one of these Kubernetes playgrounds: + +* [Katacoda](https://www.katacoda.com/courses/kubernetes/playground) +* [Play with Kubernetes](http://labs.play-with-k8s.com/) diff --git a/content/zh/includes/user-guide-content-moved.md b/content/zh/includes/user-guide-content-moved.md new file mode 100644 index 0000000000..e69de29bb2