mirror of https://github.com/k3s-io/k3s
Remove examples directory
parent
c0d1ab8e99
commit
f0b5e2d7c5
|
@ -481,7 +481,6 @@ EOF
|
|||
mkdir -p "${release_stage}/hack"
|
||||
cp -R "${KUBE_ROOT}/hack/lib" "${release_stage}/hack/"
|
||||
|
||||
cp -R "${KUBE_ROOT}/examples" "${release_stage}/"
|
||||
cp -R "${KUBE_ROOT}/docs" "${release_stage}/"
|
||||
cp "${KUBE_ROOT}/README.md" "${release_stage}/"
|
||||
cp "${KUBE_ROOT}/Godeps/LICENSES" "${release_stage}/"
|
||||
|
|
|
@ -193,7 +193,6 @@ pkg_tar(
|
|||
"//:version",
|
||||
"//cluster:all-srcs",
|
||||
"//docs:all-srcs",
|
||||
"//examples:all-srcs",
|
||||
"//hack/lib:all-srcs",
|
||||
],
|
||||
extension = "tar.gz",
|
||||
|
|
|
@ -64,7 +64,6 @@ filegroup(
|
|||
"//cluster:all-srcs",
|
||||
"//cmd:all-srcs",
|
||||
"//docs:all-srcs",
|
||||
"//examples:all-srcs",
|
||||
"//hack:all-srcs",
|
||||
"//pkg:all-srcs",
|
||||
"//plugin:all-srcs",
|
||||
|
|
|
@ -115,7 +115,7 @@ visibility = ["//visible_to:client_foo,//visible_to:server_foo"],
|
|||
```
|
||||
bazel build --check_visibility --nobuild \
|
||||
//cmd/... //pkg/... //plugin/... \
|
||||
//third_party/... //examples/... //test/... //vendor/k8s.io/...
|
||||
//third_party/... //test/... //vendor/k8s.io/...
|
||||
```
|
||||
|
||||
#### Who depends on target _q_?
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "config",
|
||||
srcs = glob([
|
||||
"**/*.yaml",
|
||||
"**/*.yml",
|
||||
"**/*.json",
|
||||
]) + [
|
||||
"pod",
|
||||
],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["doc.go"],
|
||||
importpath = "k8s.io/kubernetes/examples",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_xtest",
|
||||
srcs = ["examples_test.go"],
|
||||
tags = ["manual"], # this test is broken and examples in-tree is deprecated
|
||||
deps = [
|
||||
"//pkg/api/testapi:go_default_library",
|
||||
"//pkg/apis/apps:go_default_library",
|
||||
"//pkg/apis/apps/validation:go_default_library",
|
||||
"//pkg/apis/batch:go_default_library",
|
||||
"//pkg/apis/core:go_default_library",
|
||||
"//pkg/apis/core/validation:go_default_library",
|
||||
"//pkg/apis/extensions:go_default_library",
|
||||
"//pkg/apis/extensions/validation:go_default_library",
|
||||
"//pkg/capabilities:go_default_library",
|
||||
"//pkg/registry/batch/job:go_default_library",
|
||||
"//pkg/scheduler/api:go_default_library",
|
||||
"//pkg/scheduler/api/latest:go_default_library",
|
||||
"//pkg/scheduler/api/validation:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/yaml:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//examples/explorer:all-srcs",
|
||||
"//examples/guestbook-go:all-srcs",
|
||||
"//examples/https-nginx:all-srcs",
|
||||
"//examples/sharing-clusters:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
)
|
|
@ -1,10 +0,0 @@
|
|||
reviewers:
|
||||
- brendandburns
|
||||
- thockin
|
||||
- zmerlynn
|
||||
- zouyee
|
||||
approvers:
|
||||
- brendandburns
|
||||
- eparis
|
||||
- thockin
|
||||
- zmerlynn
|
|
@ -1 +0,0 @@
|
|||
This file has moved to [https://github.com/kubernetes/examples/blob/master/README.md](https://github.com/kubernetes/examples/blob/master/README.md)
|
|
@ -1,13 +0,0 @@
|
|||
kind: InitializerConfiguration
|
||||
apiVersion: admissionregistration.k8s.io/v1alpha1
|
||||
metadata:
|
||||
name: pvlabel.kubernetes.io
|
||||
initializers:
|
||||
- name: pvlabel.kubernetes.io
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
apiVersions:
|
||||
- "*"
|
||||
resources:
|
||||
- persistentvolumes
|
|
@ -1 +0,0 @@
|
|||
This file has moved to [https://github.com/kubernetes/examples/blob/master/staging/cluster-dns/README.md](https://github.com/kubernetes/examples/blob/master/staging/cluster-dns/README.md)
|
|
@ -1,21 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: ReplicationController
|
||||
metadata:
|
||||
name: dns-backend
|
||||
labels:
|
||||
name: dns-backend
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
name: dns-backend
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
name: dns-backend
|
||||
spec:
|
||||
containers:
|
||||
- name: dns-backend
|
||||
image: k8s.gcr.io/example-dns-backend:v1
|
||||
ports:
|
||||
- name: backend-port
|
||||
containerPort: 8000
|
|
@ -1,9 +0,0 @@
|
|||
kind: Service
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: dns-backend
|
||||
spec:
|
||||
ports:
|
||||
- port: 8000
|
||||
selector:
|
||||
name: dns-backend
|
|
@ -1,16 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: dns-frontend
|
||||
labels:
|
||||
name: dns-frontend
|
||||
spec:
|
||||
containers:
|
||||
- name: dns-frontend
|
||||
image: k8s.gcr.io/example-dns-frontend:v1
|
||||
command:
|
||||
- python
|
||||
- client.py
|
||||
- http://dns-backend.development.svc.cluster.local:8000
|
||||
imagePullPolicy: Always
|
||||
restartPolicy: Never
|
|
@ -1,20 +0,0 @@
|
|||
# Copyright 2016 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM python:2.7-slim
|
||||
|
||||
COPY . /dns-backend
|
||||
WORKDIR /dns-backend
|
||||
|
||||
CMD ["python", "server.py"]
|
|
@ -1,27 +0,0 @@
|
|||
# Copyright 2016 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
TAG = v1
|
||||
PREFIX = staging-k8s.gcr.io
|
||||
IMAGE = example-dns-backend
|
||||
|
||||
all: push
|
||||
|
||||
image:
|
||||
docker build --pull -t $(PREFIX)/$(IMAGE):$(TAG) .
|
||||
|
||||
push: image
|
||||
gcloud docker -- push $(PREFIX)/$(IMAGE)
|
||||
|
||||
clean:
|
|
@ -1,37 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Copyright 2015 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
||||
|
||||
PORT_NUMBER = 8000
|
||||
|
||||
# This class will handles any incoming request.
|
||||
class HTTPHandler(BaseHTTPRequestHandler):
|
||||
# Handler for the GET requests
|
||||
def do_GET(self):
|
||||
self.send_response(200)
|
||||
self.send_header('Content-type','text/html')
|
||||
self.end_headers()
|
||||
self.wfile.write("Hello World!")
|
||||
|
||||
try:
|
||||
# Create a web server and define the handler to manage the incoming request.
|
||||
server = HTTPServer(('', PORT_NUMBER), HTTPHandler)
|
||||
print 'Started httpserver on port ' , PORT_NUMBER
|
||||
server.serve_forever()
|
||||
except KeyboardInterrupt:
|
||||
print '^C received, shutting down the web server'
|
||||
server.socket.close()
|
|
@ -1,22 +0,0 @@
|
|||
# Copyright 2016 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM python:2.7-slim
|
||||
|
||||
RUN pip install requests
|
||||
|
||||
COPY . /dns-frontend
|
||||
WORKDIR /dns-frontend
|
||||
|
||||
CMD ["python", "client.py"]
|
|
@ -1,27 +0,0 @@
|
|||
# Copyright 2016 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
TAG = v1
|
||||
PREFIX = staging-k8s.gcr.io
|
||||
IMAGE = example-dns-frontend
|
||||
|
||||
all: push
|
||||
|
||||
image:
|
||||
docker build --pull -t $(PREFIX)/$(IMAGE):$(TAG) .
|
||||
|
||||
push: image
|
||||
gcloud docker -- push $(PREFIX)/$(IMAGE)
|
||||
|
||||
clean:
|
|
@ -1,46 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Copyright 2015 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import argparse
|
||||
import requests
|
||||
import socket
|
||||
|
||||
from urlparse import urlparse
|
||||
|
||||
|
||||
def CheckServiceAddress(address):
|
||||
hostname = urlparse(address).hostname
|
||||
service_address = socket.gethostbyname(hostname)
|
||||
print service_address
|
||||
|
||||
|
||||
def GetServerResponse(address):
|
||||
print 'Send request to:', address
|
||||
response = requests.get(address)
|
||||
print response
|
||||
print response.content
|
||||
|
||||
|
||||
def Main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('address')
|
||||
args = parser.parse_args()
|
||||
CheckServiceAddress(args.address)
|
||||
GetServerResponse(args.address)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
Main()
|
|
@ -1,6 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: "development"
|
||||
labels:
|
||||
name: "development"
|
|
@ -1,6 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: "production"
|
||||
labels:
|
||||
name: "production"
|
|
@ -1,4 +0,0 @@
|
|||
reviewers:
|
||||
- a-robinson
|
||||
approvers:
|
||||
- a-robinson
|
|
@ -1 +0,0 @@
|
|||
This file has moved to [https://github.com/kubernetes/examples/blob/master/staging/cockroachdb/README.md](https://github.com/kubernetes/examples/blob/master/staging/cockroachdb/README.md)
|
|
@ -1,171 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
# This service is meant to be used by clients of the database. It exposes a ClusterIP that will
|
||||
# automatically load balance connections to the different database pods.
|
||||
name: cockroachdb-public
|
||||
labels:
|
||||
app: cockroachdb
|
||||
spec:
|
||||
ports:
|
||||
# The main port, served by gRPC, serves Postgres-flavor SQL, internode
|
||||
# traffic and the cli.
|
||||
- port: 26257
|
||||
targetPort: 26257
|
||||
name: grpc
|
||||
# The secondary port serves the UI as well as health and debug endpoints.
|
||||
- port: 8080
|
||||
targetPort: 8080
|
||||
name: http
|
||||
selector:
|
||||
app: cockroachdb
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
# This service only exists to create DNS entries for each pod in the stateful
|
||||
# set such that they can resolve each other's IP addresses. It does not
|
||||
# create a load-balanced ClusterIP and should not be used directly by clients
|
||||
# in most circumstances.
|
||||
name: cockroachdb
|
||||
labels:
|
||||
app: cockroachdb
|
||||
annotations:
|
||||
# This is needed to make the peer-finder work properly and to help avoid
|
||||
# edge cases where instance 0 comes up after losing its data and needs to
|
||||
# decide whether it should create a new cluster or try to join an existing
|
||||
# one. If it creates a new cluster when it should have joined an existing
|
||||
# one, we'd end up with two separate clusters listening at the same service
|
||||
# endpoint, which would be very bad.
|
||||
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
|
||||
# Enable automatic monitoring of all instances when Prometheus is running in the cluster.
|
||||
prometheus.io/scrape: "true"
|
||||
prometheus.io/path: "_status/vars"
|
||||
prometheus.io/port: "8080"
|
||||
spec:
|
||||
ports:
|
||||
- port: 26257
|
||||
targetPort: 26257
|
||||
name: grpc
|
||||
- port: 8080
|
||||
targetPort: 8080
|
||||
name: http
|
||||
clusterIP: None
|
||||
selector:
|
||||
app: cockroachdb
|
||||
---
|
||||
apiVersion: policy/v1beta1
|
||||
kind: PodDisruptionBudget
|
||||
metadata:
|
||||
name: cockroachdb-budget
|
||||
labels:
|
||||
app: cockroachdb
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: cockroachdb
|
||||
minAvailable: 67%
|
||||
---
|
||||
apiVersion: apps/v1beta1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: cockroachdb
|
||||
spec:
|
||||
serviceName: "cockroachdb"
|
||||
replicas: 3
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: cockroachdb
|
||||
spec:
|
||||
# Init containers are run only once in the lifetime of a pod, before
|
||||
# it's started up for the first time. It has to exit successfully
|
||||
# before the pod's main containers are allowed to start.
|
||||
# This particular init container does a DNS lookup for other pods in
|
||||
# the set to help determine whether or not a cluster already exists.
|
||||
# If any other pods exist, it creates a file in the cockroach-data
|
||||
# directory to pass that information along to the primary container that
|
||||
# has to decide what command-line flags to use when starting CockroachDB.
|
||||
# This only matters when a pod's persistent volume is empty - if it has
|
||||
# data from a previous execution, that data will always be used.
|
||||
#
|
||||
# If your Kubernetes cluster uses a custom DNS domain, you will have
|
||||
# to add an additional arg to this pod: "-domain=<your-custom-domain>"
|
||||
initContainers:
|
||||
- name: bootstrap
|
||||
image: cockroachdb/cockroach-k8s-init:0.2
|
||||
imagePullPolicy: IfNotPresent
|
||||
args:
|
||||
- "-on-start=/on-start.sh"
|
||||
- "-service=cockroachdb"
|
||||
env:
|
||||
- name: POD_NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.namespace
|
||||
volumeMounts:
|
||||
- name: datadir
|
||||
mountPath: "/cockroach/cockroach-data"
|
||||
affinity:
|
||||
podAntiAffinity:
|
||||
preferredDuringSchedulingIgnoredDuringExecution:
|
||||
- weight: 100
|
||||
podAffinityTerm:
|
||||
labelSelector:
|
||||
matchExpressions:
|
||||
- key: app
|
||||
operator: In
|
||||
values:
|
||||
- cockroachdb
|
||||
topologyKey: kubernetes.io/hostname
|
||||
containers:
|
||||
- name: cockroachdb
|
||||
image: cockroachdb/cockroach:v1.1.0
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 26257
|
||||
name: grpc
|
||||
- containerPort: 8080
|
||||
name: http
|
||||
volumeMounts:
|
||||
- name: datadir
|
||||
mountPath: /cockroach/cockroach-data
|
||||
command:
|
||||
- "/bin/bash"
|
||||
- "-ecx"
|
||||
- |
|
||||
# The use of qualified `hostname -f` is crucial:
|
||||
# Other nodes aren't able to look up the unqualified hostname.
|
||||
CRARGS=("start" "--logtostderr" "--insecure" "--host" "$(hostname -f)" "--http-host" "0.0.0.0")
|
||||
# We only want to initialize a new cluster (by omitting the join flag)
|
||||
# if we're sure that we're the first node (i.e. index 0) and that
|
||||
# there aren't any other nodes running as part of the cluster that
|
||||
# this is supposed to be a part of (which indicates that a cluster
|
||||
# already exists and we should make sure not to create a new one).
|
||||
# It's fine to run without --join on a restart if there aren't any
|
||||
# other nodes.
|
||||
if [ ! "$(hostname)" == "cockroachdb-0" ] || \
|
||||
[ -e "/cockroach/cockroach-data/cluster_exists_marker" ]
|
||||
then
|
||||
# We don't join cockroachdb in order to avoid a node attempting
|
||||
# to join itself, which currently doesn't work
|
||||
# (https://github.com/cockroachdb/cockroach/issues/9625).
|
||||
CRARGS+=("--join" "cockroachdb-public")
|
||||
fi
|
||||
exec /cockroach/cockroach ${CRARGS[*]}
|
||||
# No pre-stop hook is required, a SIGTERM plus some time is all that's
|
||||
# needed for graceful shutdown of a node.
|
||||
terminationGracePeriodSeconds: 60
|
||||
volumes:
|
||||
- name: datadir
|
||||
persistentVolumeClaim:
|
||||
claimName: datadir
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: datadir
|
||||
spec:
|
||||
accessModes:
|
||||
- "ReadWriteOnce"
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
|
@ -1,48 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2016 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
function sql() {
|
||||
# TODO(knz): Why does the more idiomatic read from stdin not produce any
|
||||
# output?
|
||||
kubectl exec "cockroachdb-${1}" -- /cockroach/cockroach sql \
|
||||
--host "cockroachdb-${1}.cockroachdb" \
|
||||
--insecure \
|
||||
-e "$(cat /dev/stdin)"
|
||||
}
|
||||
|
||||
function kill() {
|
||||
! kubectl exec -t "cockroachdb-${1}" -- /bin/bash -c "while true; do kill 1; done" &> /dev/null
|
||||
}
|
||||
|
||||
# Create database on second node (idempotently for convenience).
|
||||
cat <<EOF | sql 1
|
||||
CREATE DATABASE IF NOT EXISTS foo;
|
||||
CREATE TABLE IF NOT EXISTS foo.bar (k STRING PRIMARY KEY, v STRING);
|
||||
UPSERT INTO foo.bar VALUES ('Kuber', 'netes'), ('Cockroach', 'DB');
|
||||
EOF
|
||||
|
||||
# Kill the node we just created the table on.
|
||||
kill 1
|
||||
|
||||
# Read the data from all other nodes (we could also read from the one we just
|
||||
# killed, but it's awkward to wait for it to respawn).
|
||||
for i in 0 2 3 4; do
|
||||
cat <<EOF | sql "${i}"
|
||||
SELECT CONCAT(k, v) FROM foo.bar;
|
||||
EOF
|
||||
done
|
|
@ -1,72 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2016 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Run the CockroachDB StatefulSet example on a minikube instance.
|
||||
#
|
||||
# For a fresh start, run the following first:
|
||||
# minikube delete
|
||||
# minikube start
|
||||
#
|
||||
# To upgrade minikube & kubectl on OSX, the following should suffice:
|
||||
# brew reinstall kubernetes-cli --devel
|
||||
# url -Lo minikube \
|
||||
# https://storage.googleapis.com/minikube/releases/v0.4.0/minikube-darwin-amd64 && \
|
||||
# chmod +x minikube && sudo mv minikube /usr/local/bin/
|
||||
|
||||
set -exuo pipefail
|
||||
|
||||
# Clean up anything from a prior run:
|
||||
kubectl delete statefulsets,persistentvolumes,persistentvolumeclaims,services,poddisruptionbudget -l app=cockroachdb
|
||||
|
||||
# Make persistent volumes and (correctly named) claims. We must create the
|
||||
# claims here manually even though that sounds counter-intuitive. For details
|
||||
# see https://github.com/kubernetes/contrib/pull/1295#issuecomment-230180894.
|
||||
# Note that we make an extra volume here so you can manually test scale-up.
|
||||
for i in $(seq 0 3); do
|
||||
cat <<EOF | kubectl create -f -
|
||||
kind: PersistentVolume
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: pv${i}
|
||||
labels:
|
||||
type: local
|
||||
app: cockroachdb
|
||||
spec:
|
||||
capacity:
|
||||
storage: 1Gi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
hostPath:
|
||||
path: "/tmp/${i}"
|
||||
EOF
|
||||
|
||||
cat <<EOF | kubectl create -f -
|
||||
kind: PersistentVolumeClaim
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: datadir-cockroachdb-${i}
|
||||
labels:
|
||||
app: cockroachdb
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
EOF
|
||||
done;
|
||||
|
||||
kubectl create -f cockroachdb-statefulset.yaml
|
|
@ -1,6 +0,0 @@
|
|||
approvers:
|
||||
- derekwaynecarr
|
||||
- vishh
|
||||
- ConnorDoyle
|
||||
- sjenning
|
||||
- balajismaniam
|
|
@ -1,62 +0,0 @@
|
|||
# CPU Manager Example
|
||||
|
||||
This example flow uses a pre-built docker image based on
|
||||
[cpuset-visualizer](https://github.com/ConnorDoyle/cpuset-visualizer).
|
||||
Each container run here hosts an endpoint serving an up-to-the-second
|
||||
system representation generated by
|
||||
[`lstopo`](https://www.open-mpi.org/projects/hwloc).
|
||||
|
||||
## Setup
|
||||
|
||||
1. Start a local cluster with the static CPU manager policy enabled :
|
||||
|
||||
```
|
||||
sudo PATH=$PATH \
|
||||
KUBELET_FLAGS="\
|
||||
--feature-gates=CPUManager=true \
|
||||
--cpu-manager-policy=static \
|
||||
--cpu-manager-reconcile-period=5s \
|
||||
--kube-reserved=cpu=500m" \
|
||||
./hack/local-up-cluster.sh
|
||||
```
|
||||
|
||||
## Run pods
|
||||
|
||||
The example pods are in the `/examples/cpu-manager` directory of the
|
||||
Kubernetes source tree. Your ability to run all of the example pods
|
||||
simultaneously depends on how many CPUs are available on the test system.
|
||||
|
||||
The required CPUs for each example pod are listed below:
|
||||
|
||||
```
|
||||
POD | CPUs
|
||||
------------------|---------
|
||||
be.yaml | >= 1 CPU
|
||||
shared.yaml | >= 1 CPU
|
||||
exclusive-1.yaml | >= 2 CPU
|
||||
exclusive-2.yaml | >= 3 CPU
|
||||
exclusive-3.yaml | >= 4 CPU
|
||||
exclusive-4.yaml | >= 5 CPU
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
Run a pod with a single container in the shared pool, and another pod
|
||||
with a single container in an exclusive cpuset with one CPU.
|
||||
|
||||
```
|
||||
$ kubectl create -f examples/cpu-manager/shared.yaml
|
||||
$ kubectl create -f examples/cpu-manager/exclusive-1.yaml
|
||||
```
|
||||
|
||||
To list IP addresses of the pods running in the local cluster, do:
|
||||
|
||||
```
|
||||
$ watch ./examples/cpu-manager/pod-ips
|
||||
exclusive-1 http://172.17.0.4
|
||||
shared http://172.17.0.3
|
||||
```
|
||||
|
||||
#### Sample cpuset-visualizer output
|
||||
|
||||
![Sample cpuset-visualizer output](https://user-images.githubusercontent.com/379372/28648573-974693ce-7223-11e7-84ed-17cce11910ff.png)
|
|
@ -1,8 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: be
|
||||
spec:
|
||||
containers:
|
||||
- image: quay.io/connordoyle/cpuset-visualizer
|
||||
name: be
|
|
@ -1,15 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: exclusive-1
|
||||
spec:
|
||||
containers:
|
||||
- image: quay.io/connordoyle/cpuset-visualizer
|
||||
name: exclusive-1
|
||||
resources:
|
||||
requests:
|
||||
cpu: 1
|
||||
memory: "256M"
|
||||
limits:
|
||||
cpu: 1
|
||||
memory: "256M"
|
|
@ -1,15 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: exclusive-2
|
||||
spec:
|
||||
containers:
|
||||
- image: quay.io/connordoyle/cpuset-visualizer
|
||||
name: exclusive-2
|
||||
resources:
|
||||
requests:
|
||||
cpu: 2
|
||||
memory: "256M"
|
||||
limits:
|
||||
cpu: 2
|
||||
memory: "256M"
|
|
@ -1,15 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: exclusive-3
|
||||
spec:
|
||||
containers:
|
||||
- image: quay.io/connordoyle/cpuset-visualizer
|
||||
name: exclusive-3
|
||||
resources:
|
||||
requests:
|
||||
cpu: 3
|
||||
memory: "256M"
|
||||
limits:
|
||||
cpu: 3
|
||||
memory: "256M"
|
|
@ -1,15 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: exclusive-4
|
||||
spec:
|
||||
containers:
|
||||
- image: quay.io/connordoyle/cpuset-visualizer
|
||||
name: exclusive-4
|
||||
resources:
|
||||
requests:
|
||||
cpu: 4
|
||||
memory: "256M"
|
||||
limits:
|
||||
cpu: 4
|
||||
memory: "256M"
|
|
@ -1,26 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright 2017 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Requires `jq`. See https://stedolan.github.io/jq/download
|
||||
|
||||
set -o nounset -o pipefail -o errexit
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
KUBECTL="$DIR/../../cluster/kubectl.sh"
|
||||
export KUBECONFIG="${KUBECONFIG:-/var/run/kubernetes/admin.kubeconfig}"
|
||||
|
||||
$KUBECTL get pods -o json | \
|
||||
jq -r '.items[] | "\(.metadata.name) http://\(.status.podIP)"'
|
|
@ -1,11 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: shared
|
||||
spec:
|
||||
containers:
|
||||
- image: quay.io/connordoyle/cpuset-visualizer
|
||||
name: shared
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
|
@ -1,18 +0,0 @@
|
|||
/*
|
||||
Copyright 2014 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Examples contains sample applications for trying out the concepts in Kubernetes.
|
||||
package examples // import "k8s.io/kubernetes/examples"
|
|
@ -1 +0,0 @@
|
|||
This file has moved to [https://github.com/kubernetes/examples/blob/master/staging/elasticsearch/README.md](https://github.com/kubernetes/examples/blob/master/staging/elasticsearch/README.md)
|
|
@ -1,466 +0,0 @@
|
|||
/*
|
||||
Copyright 2014 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package examples_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
"k8s.io/apimachinery/pkg/util/yaml"
|
||||
"k8s.io/kubernetes/pkg/api/testapi"
|
||||
"k8s.io/kubernetes/pkg/apis/apps"
|
||||
appsvalidation "k8s.io/kubernetes/pkg/apis/apps/validation"
|
||||
"k8s.io/kubernetes/pkg/apis/batch"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
"k8s.io/kubernetes/pkg/apis/core/validation"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
expvalidation "k8s.io/kubernetes/pkg/apis/extensions/validation"
|
||||
"k8s.io/kubernetes/pkg/capabilities"
|
||||
"k8s.io/kubernetes/pkg/registry/batch/job"
|
||||
schedulerapi "k8s.io/kubernetes/pkg/scheduler/api"
|
||||
schedulerapilatest "k8s.io/kubernetes/pkg/scheduler/api/latest"
|
||||
schedulerapivalidation "k8s.io/kubernetes/pkg/scheduler/api/validation"
|
||||
)
|
||||
|
||||
func validateObject(obj runtime.Object) (errors field.ErrorList) {
|
||||
switch t := obj.(type) {
|
||||
case *api.ReplicationController:
|
||||
if t.Namespace == "" {
|
||||
t.Namespace = metav1.NamespaceDefault
|
||||
}
|
||||
errors = validation.ValidateReplicationController(t)
|
||||
case *api.ReplicationControllerList:
|
||||
for i := range t.Items {
|
||||
errors = append(errors, validateObject(&t.Items[i])...)
|
||||
}
|
||||
case *api.Service:
|
||||
if t.Namespace == "" {
|
||||
t.Namespace = metav1.NamespaceDefault
|
||||
}
|
||||
errors = validation.ValidateService(t)
|
||||
case *api.ServiceList:
|
||||
for i := range t.Items {
|
||||
errors = append(errors, validateObject(&t.Items[i])...)
|
||||
}
|
||||
case *api.Pod:
|
||||
if t.Namespace == "" {
|
||||
t.Namespace = metav1.NamespaceDefault
|
||||
}
|
||||
errors = validation.ValidatePod(t)
|
||||
case *api.PodList:
|
||||
for i := range t.Items {
|
||||
errors = append(errors, validateObject(&t.Items[i])...)
|
||||
}
|
||||
case *api.PersistentVolume:
|
||||
errors = validation.ValidatePersistentVolume(t)
|
||||
case *api.PersistentVolumeClaim:
|
||||
if t.Namespace == "" {
|
||||
t.Namespace = metav1.NamespaceDefault
|
||||
}
|
||||
errors = validation.ValidatePersistentVolumeClaim(t)
|
||||
case *api.PodTemplate:
|
||||
if t.Namespace == "" {
|
||||
t.Namespace = metav1.NamespaceDefault
|
||||
}
|
||||
errors = validation.ValidatePodTemplate(t)
|
||||
case *api.Endpoints:
|
||||
if t.Namespace == "" {
|
||||
t.Namespace = metav1.NamespaceDefault
|
||||
}
|
||||
errors = validation.ValidateEndpoints(t)
|
||||
case *api.Namespace:
|
||||
errors = validation.ValidateNamespace(t)
|
||||
case *api.Secret:
|
||||
if t.Namespace == "" {
|
||||
t.Namespace = metav1.NamespaceDefault
|
||||
}
|
||||
errors = validation.ValidateSecret(t)
|
||||
case *api.LimitRange:
|
||||
if t.Namespace == "" {
|
||||
t.Namespace = metav1.NamespaceDefault
|
||||
}
|
||||
errors = validation.ValidateLimitRange(t)
|
||||
case *api.ResourceQuota:
|
||||
if t.Namespace == "" {
|
||||
t.Namespace = metav1.NamespaceDefault
|
||||
}
|
||||
errors = validation.ValidateResourceQuota(t)
|
||||
case *extensions.Deployment:
|
||||
if t.Namespace == "" {
|
||||
t.Namespace = metav1.NamespaceDefault
|
||||
}
|
||||
errors = expvalidation.ValidateDeployment(t)
|
||||
case *batch.Job:
|
||||
if t.Namespace == "" {
|
||||
t.Namespace = metav1.NamespaceDefault
|
||||
}
|
||||
// Job needs generateSelector called before validation, and job.Validate does this.
|
||||
// See: https://github.com/kubernetes/kubernetes/issues/20951#issuecomment-187787040
|
||||
t.ObjectMeta.UID = types.UID("fakeuid")
|
||||
errors = job.Strategy.Validate(nil, t)
|
||||
case *extensions.Ingress:
|
||||
if t.Namespace == "" {
|
||||
t.Namespace = metav1.NamespaceDefault
|
||||
}
|
||||
errors = expvalidation.ValidateIngress(t)
|
||||
case *extensions.DaemonSet:
|
||||
if t.Namespace == "" {
|
||||
t.Namespace = metav1.NamespaceDefault
|
||||
}
|
||||
errors = expvalidation.ValidateDaemonSet(t)
|
||||
case *apps.StatefulSet:
|
||||
if t.Namespace == "" {
|
||||
t.Namespace = metav1.NamespaceDefault
|
||||
}
|
||||
errors = appsvalidation.ValidateStatefulSet(t)
|
||||
default:
|
||||
errors = field.ErrorList{}
|
||||
errors = append(errors, field.InternalError(field.NewPath(""), fmt.Errorf("no validation defined for %#v", obj)))
|
||||
}
|
||||
return errors
|
||||
}
|
||||
|
||||
func validateschedulerpolicy(obj runtime.Object) error {
|
||||
switch t := obj.(type) {
|
||||
case *schedulerapi.Policy:
|
||||
return schedulerapivalidation.ValidatePolicy(*t)
|
||||
default:
|
||||
return fmt.Errorf("obj type is not schedulerapi.Policy")
|
||||
}
|
||||
}
|
||||
|
||||
func walkJSONFiles(inDir string, fn func(name, path string, data []byte)) error {
|
||||
return filepath.Walk(inDir, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if info.IsDir() && path != inDir {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
|
||||
file := filepath.Base(path)
|
||||
if ext := filepath.Ext(file); ext == ".json" || ext == ".yaml" {
|
||||
glog.Infof("Testing %s", path)
|
||||
data, err := ioutil.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
name := strings.TrimSuffix(file, ext)
|
||||
|
||||
if ext == ".yaml" {
|
||||
out, err := yaml.ToJSON(data)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s: %v", path, err)
|
||||
}
|
||||
data = out
|
||||
}
|
||||
|
||||
fn(name, path, data)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func TestExampleObjectSchemas(t *testing.T) {
|
||||
cases := map[string]map[string]runtime.Object{
|
||||
"../examples/guestbook": {
|
||||
"frontend-deployment": &extensions.Deployment{},
|
||||
"redis-slave-deployment": &extensions.Deployment{},
|
||||
"redis-master-deployment": &extensions.Deployment{},
|
||||
"frontend-service": &api.Service{},
|
||||
"redis-master-service": &api.Service{},
|
||||
"redis-slave-service": &api.Service{},
|
||||
},
|
||||
"../examples/guestbook/legacy": {
|
||||
"frontend-controller": &api.ReplicationController{},
|
||||
"redis-slave-controller": &api.ReplicationController{},
|
||||
"redis-master-controller": &api.ReplicationController{},
|
||||
},
|
||||
"../examples/guestbook-go": {
|
||||
"guestbook-controller": &api.ReplicationController{},
|
||||
"redis-slave-controller": &api.ReplicationController{},
|
||||
"redis-master-controller": &api.ReplicationController{},
|
||||
"guestbook-service": &api.Service{},
|
||||
"redis-master-service": &api.Service{},
|
||||
"redis-slave-service": &api.Service{},
|
||||
},
|
||||
"../examples/volumes/iscsi": {
|
||||
"chap-secret": &api.Secret{},
|
||||
"iscsi": &api.Pod{},
|
||||
"iscsi-chap": &api.Pod{},
|
||||
},
|
||||
"../examples/volumes/glusterfs": {
|
||||
"glusterfs-pod": &api.Pod{},
|
||||
"glusterfs-endpoints": &api.Endpoints{},
|
||||
"glusterfs-service": &api.Service{},
|
||||
},
|
||||
"../examples": {
|
||||
"scheduler-policy-config": &schedulerapi.Policy{},
|
||||
"scheduler-policy-config-with-extender": &schedulerapi.Policy{},
|
||||
},
|
||||
"../examples/volumes/rbd/secret": {
|
||||
"ceph-secret": &api.Secret{},
|
||||
},
|
||||
"../examples/volumes/rbd": {
|
||||
"rbd": &api.Pod{},
|
||||
"rbd-with-secret": &api.Pod{},
|
||||
},
|
||||
"../examples/cluster-dns": {
|
||||
"dns-backend-rc": &api.ReplicationController{},
|
||||
"dns-backend-service": &api.Service{},
|
||||
"dns-frontend-pod": &api.Pod{},
|
||||
"namespace-dev": &api.Namespace{},
|
||||
"namespace-prod": &api.Namespace{},
|
||||
},
|
||||
"../examples/explorer": {
|
||||
"pod": &api.Pod{},
|
||||
},
|
||||
"../examples/storage/hazelcast": {
|
||||
"hazelcast-deployment": &extensions.Deployment{},
|
||||
"hazelcast-service": &api.Service{},
|
||||
},
|
||||
"../examples/meteor": {
|
||||
"meteor-controller": &api.ReplicationController{},
|
||||
"meteor-service": &api.Service{},
|
||||
"mongo-pod": &api.Pod{},
|
||||
"mongo-service": &api.Service{},
|
||||
},
|
||||
"../examples/mysql-wordpress-pd": {
|
||||
"gce-volumes": &api.PersistentVolume{},
|
||||
"local-volumes": &api.PersistentVolume{},
|
||||
"mysql-deployment": &api.Service{},
|
||||
"wordpress-deployment": &api.Service{},
|
||||
},
|
||||
"../examples/volumes/nfs": {
|
||||
"nfs-busybox-rc": &api.ReplicationController{},
|
||||
"nfs-server-rc": &api.ReplicationController{},
|
||||
"nfs-server-service": &api.Service{},
|
||||
"nfs-pv": &api.PersistentVolume{},
|
||||
"nfs-pvc": &api.PersistentVolumeClaim{},
|
||||
"nfs-web-rc": &api.ReplicationController{},
|
||||
"nfs-web-service": &api.Service{},
|
||||
},
|
||||
"../examples/openshift-origin": {
|
||||
"openshift-origin-namespace": &api.Namespace{},
|
||||
"openshift-controller": &extensions.Deployment{},
|
||||
"openshift-service": &api.Service{},
|
||||
"etcd-controller": &extensions.Deployment{},
|
||||
"etcd-service": &api.Service{},
|
||||
"etcd-discovery-controller": &extensions.Deployment{},
|
||||
"etcd-discovery-service": &api.Service{},
|
||||
"secret": nil,
|
||||
},
|
||||
"../examples/phabricator": {
|
||||
"phabricator-controller": &api.ReplicationController{},
|
||||
"phabricator-service": &api.Service{},
|
||||
},
|
||||
"../examples/storage/redis": {
|
||||
"redis-controller": &api.ReplicationController{},
|
||||
"redis-master": &api.Pod{},
|
||||
"redis-sentinel-controller": &api.ReplicationController{},
|
||||
"redis-sentinel-service": &api.Service{},
|
||||
},
|
||||
"../examples/storage/rethinkdb": {
|
||||
"admin-pod": &api.Pod{},
|
||||
"admin-service": &api.Service{},
|
||||
"driver-service": &api.Service{},
|
||||
"rc": &api.ReplicationController{},
|
||||
},
|
||||
"../examples/spark": {
|
||||
"namespace-spark-cluster": &api.Namespace{},
|
||||
"spark-master-controller": &api.ReplicationController{},
|
||||
"spark-master-service": &api.Service{},
|
||||
"spark-ui-proxy-controller": &api.ReplicationController{},
|
||||
"spark-ui-proxy-service": &api.Service{},
|
||||
"spark-worker-controller": &api.ReplicationController{},
|
||||
"zeppelin-controller": &api.ReplicationController{},
|
||||
"zeppelin-service": &api.Service{},
|
||||
},
|
||||
"../examples/spark/spark-gluster": {
|
||||
"spark-master-service": &api.Service{},
|
||||
"spark-master-controller": &api.ReplicationController{},
|
||||
"spark-worker-controller": &api.ReplicationController{},
|
||||
"glusterfs-endpoints": &api.Endpoints{},
|
||||
},
|
||||
"../examples/storm": {
|
||||
"storm-nimbus-service": &api.Service{},
|
||||
"storm-nimbus": &api.Pod{},
|
||||
"storm-worker-controller": &api.ReplicationController{},
|
||||
"zookeeper-service": &api.Service{},
|
||||
"zookeeper": &api.Pod{},
|
||||
},
|
||||
"../examples/volumes/cephfs/": {
|
||||
"cephfs": &api.Pod{},
|
||||
"cephfs-with-secret": &api.Pod{},
|
||||
},
|
||||
"../examples/volumes/fibre_channel": {
|
||||
"fc": &api.Pod{},
|
||||
},
|
||||
"../examples/javaweb-tomcat-sidecar": {
|
||||
"javaweb": &api.Pod{},
|
||||
"javaweb-2": &api.Pod{},
|
||||
},
|
||||
"../examples/volumes/azure_file": {
|
||||
"azure": &api.Pod{},
|
||||
},
|
||||
"../examples/volumes/azure_disk": {
|
||||
"azure": &api.Pod{},
|
||||
},
|
||||
}
|
||||
|
||||
capabilities.SetForTests(capabilities.Capabilities{
|
||||
AllowPrivileged: true,
|
||||
})
|
||||
|
||||
for path, expected := range cases {
|
||||
tested := 0
|
||||
err := walkJSONFiles(path, func(name, path string, data []byte) {
|
||||
expectedType, found := expected[name]
|
||||
if !found {
|
||||
t.Errorf("%s: %s does not have a test case defined", path, name)
|
||||
return
|
||||
}
|
||||
tested++
|
||||
if expectedType == nil {
|
||||
t.Logf("skipping : %s/%s\n", path, name)
|
||||
return
|
||||
}
|
||||
if strings.Contains(name, "scheduler-policy-config") {
|
||||
if err := runtime.DecodeInto(schedulerapilatest.Codec, data, expectedType); err != nil {
|
||||
t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
|
||||
return
|
||||
}
|
||||
if err := validateschedulerpolicy(expectedType); err != nil {
|
||||
t.Errorf("%s did not validate correctly: %v\n%s", path, err, string(data))
|
||||
return
|
||||
}
|
||||
} else {
|
||||
codec, err := testapi.GetCodecForObject(expectedType)
|
||||
if err != nil {
|
||||
t.Errorf("Could not get codec for %s: %s", expectedType, err)
|
||||
}
|
||||
if err := runtime.DecodeInto(codec, data, expectedType); err != nil {
|
||||
t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
|
||||
return
|
||||
}
|
||||
if errors := validateObject(expectedType); len(errors) > 0 {
|
||||
t.Errorf("%s did not validate correctly: %v", path, errors)
|
||||
}
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("Expected no error, Got %v", err)
|
||||
}
|
||||
if tested != len(expected) {
|
||||
t.Errorf("Directory %v: Expected %d examples, Got %d", path, len(expected), tested)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This regex is tricky, but it works. For future me, here is the decode:
|
||||
//
|
||||
// Flags: (?ms) = multiline match, allow . to match \n
|
||||
// 1) Look for a line that starts with ``` (a markdown code block)
|
||||
// 2) (?: ... ) = non-capturing group
|
||||
// 3) (P<name>) = capture group as "name"
|
||||
// 4) Look for #1 followed by either:
|
||||
// 4a) "yaml" followed by any word-characters followed by a newline (e.g. ```yamlfoo\n)
|
||||
// 4b) "any word-characters followed by a newline (e.g. ```json\n)
|
||||
// 5) Look for either:
|
||||
// 5a) #4a followed by one or more characters (non-greedy)
|
||||
// 5b) #4b followed by { followed by one or more characters (non-greedy) followed by }
|
||||
// 6) Look for #5 followed by a newline followed by ``` (end of the code block)
|
||||
//
|
||||
// This could probably be simplified, but is already too delicate. Before any
|
||||
// real changes, we should have a testscase that just tests this regex.
|
||||
var sampleRegexp = regexp.MustCompile("(?ms)^```(?:(?P<type>yaml)\\w*\\n(?P<content>.+?)|\\w*\\n(?P<content>\\{.+?\\}))\\n^```")
|
||||
var subsetRegexp = regexp.MustCompile("(?ms)\\.{3}")
|
||||
|
||||
func TestReadme(t *testing.T) {
|
||||
paths := []struct {
|
||||
file string
|
||||
expectedType []runtime.Object
|
||||
}{
|
||||
{"../README.md", []runtime.Object{&api.Pod{}}},
|
||||
{"../examples/volumes/iscsi/README.md", []runtime.Object{&api.Secret{}}},
|
||||
}
|
||||
|
||||
for _, path := range paths {
|
||||
data, err := ioutil.ReadFile(path.file)
|
||||
if err != nil {
|
||||
t.Errorf("Unable to read file %s: %v", path, err)
|
||||
continue
|
||||
}
|
||||
|
||||
matches := sampleRegexp.FindAllStringSubmatch(string(data), -1)
|
||||
if matches == nil {
|
||||
continue
|
||||
}
|
||||
ix := 0
|
||||
for _, match := range matches {
|
||||
var content, subtype string
|
||||
for i, name := range sampleRegexp.SubexpNames() {
|
||||
if name == "type" {
|
||||
subtype = match[i]
|
||||
}
|
||||
if name == "content" && match[i] != "" {
|
||||
content = match[i]
|
||||
}
|
||||
}
|
||||
if subtype == "yaml" && subsetRegexp.FindString(content) != "" {
|
||||
t.Logf("skipping (%s): \n%s", subtype, content)
|
||||
continue
|
||||
}
|
||||
|
||||
var expectedType runtime.Object
|
||||
if len(path.expectedType) == 1 {
|
||||
expectedType = path.expectedType[0]
|
||||
} else {
|
||||
expectedType = path.expectedType[ix]
|
||||
ix++
|
||||
}
|
||||
json, err := yaml.ToJSON([]byte(content))
|
||||
if err != nil {
|
||||
t.Errorf("%s could not be converted to JSON: %v\n%s", path, err, string(content))
|
||||
}
|
||||
if err := runtime.DecodeInto(testapi.Default.Codec(), json, expectedType); err != nil {
|
||||
t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(content))
|
||||
continue
|
||||
}
|
||||
if errors := validateObject(expectedType); len(errors) > 0 {
|
||||
t.Errorf("%s did not validate correctly: %v", path, errors)
|
||||
}
|
||||
_, err = runtime.Encode(testapi.Default.Codec(), expectedType)
|
||||
if err != nil {
|
||||
t.Errorf("Could not encode object: %v", err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "explorer",
|
||||
embed = [":go_default_library"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["explorer.go"],
|
||||
importpath = "k8s.io/kubernetes/examples/explorer",
|
||||
deps = ["//vendor/github.com/davecgh/go-spew/spew:go_default_library"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
|
@ -1,19 +0,0 @@
|
|||
# Copyright 2016 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM scratch
|
||||
ADD explorer explorer
|
||||
ADD README.md README.md
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["/explorer"]
|
|
@ -1,30 +0,0 @@
|
|||
# Copyright 2016 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
all: push
|
||||
|
||||
# Keep this one version ahead, so no one accidentally blows away the latest published version.
|
||||
TAG = 1.1
|
||||
|
||||
explorer: explorer.go
|
||||
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-w' ./explorer.go
|
||||
|
||||
container: explorer
|
||||
docker build --pull -t staging-k8s.gcr.io/explorer:$(TAG) .
|
||||
|
||||
push: container
|
||||
gcloud docker -- push staging-k8s.gcr.io/explorer:$(TAG)
|
||||
|
||||
clean:
|
||||
rm -f explorer
|
|
@ -1 +0,0 @@
|
|||
This file has moved to [https://github.com/kubernetes/examples/blob/master/staging/explorer/README.md](https://github.com/kubernetes/examples/blob/master/staging/explorer/README.md)
|
|
@ -1,122 +0,0 @@
|
|||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// A tiny web server for viewing the environment kubernetes creates for your
|
||||
// containers. It exposes the filesystem and environment variables via http
|
||||
// server.
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
)
|
||||
|
||||
var (
|
||||
port = flag.Int("port", 8080, "Port number to serve at.")
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
hostname, err := os.Hostname()
|
||||
if err != nil {
|
||||
log.Fatalf("Error getting hostname: %v", err)
|
||||
}
|
||||
|
||||
links := []struct {
|
||||
link, desc string
|
||||
}{
|
||||
{"/fs/", "Complete file system as seen by this container."},
|
||||
{"/vars/", "Environment variables as seen by this container."},
|
||||
{"/hostname/", "Hostname as seen by this container."},
|
||||
{"/dns?q=google.com", "Explore DNS records seen by this container."},
|
||||
{"/quit", "Cause this container to exit."},
|
||||
}
|
||||
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, "<b> Kubernetes environment explorer </b><br/><br/>")
|
||||
for _, v := range links {
|
||||
fmt.Fprintf(w, `<a href="%v">%v: %v</a><br/>`, v.link, v.link, v.desc)
|
||||
}
|
||||
})
|
||||
|
||||
http.Handle("/fs/", http.StripPrefix("/fs/", http.FileServer(http.Dir("/"))))
|
||||
http.HandleFunc("/vars/", func(w http.ResponseWriter, r *http.Request) {
|
||||
for _, v := range os.Environ() {
|
||||
fmt.Fprintf(w, "%v\n", v)
|
||||
}
|
||||
})
|
||||
http.HandleFunc("/hostname/", func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, hostname)
|
||||
})
|
||||
http.HandleFunc("/quit", func(w http.ResponseWriter, r *http.Request) {
|
||||
os.Exit(0)
|
||||
})
|
||||
http.HandleFunc("/dns", dns)
|
||||
|
||||
go log.Fatal(http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", *port), nil))
|
||||
|
||||
select {}
|
||||
}
|
||||
|
||||
func dns(w http.ResponseWriter, r *http.Request) {
|
||||
q := r.URL.Query().Get("q")
|
||||
// Note that the below is NOT safe from input attacks, but that's OK
|
||||
// because this is just for debugging.
|
||||
fmt.Fprintf(w, `<html><body>
|
||||
<form action="/dns">
|
||||
<input name="q" type="text" value="%v"></input>
|
||||
<button type="submit">Lookup</button>
|
||||
</form>
|
||||
<br/><br/><pre>`, q)
|
||||
{
|
||||
res, err := net.LookupNS(q)
|
||||
spew.Fprintf(w, "LookupNS(%v):\nResult: %#v\nError: %v\n\n", q, res, err)
|
||||
}
|
||||
{
|
||||
res, err := net.LookupTXT(q)
|
||||
spew.Fprintf(w, "LookupTXT(%v):\nResult: %#v\nError: %v\n\n", q, res, err)
|
||||
}
|
||||
{
|
||||
cname, res, err := net.LookupSRV("", "", q)
|
||||
spew.Fprintf(w, `LookupSRV("", "", %v):
|
||||
cname: %v
|
||||
Result: %#v
|
||||
Error: %v
|
||||
|
||||
`, q, cname, res, err)
|
||||
}
|
||||
{
|
||||
res, err := net.LookupHost(q)
|
||||
spew.Fprintf(w, "LookupHost(%v):\nResult: %#v\nError: %v\n\n", q, res, err)
|
||||
}
|
||||
{
|
||||
res, err := net.LookupIP(q)
|
||||
spew.Fprintf(w, "LookupIP(%v):\nResult: %#v\nError: %v\n\n", q, res, err)
|
||||
}
|
||||
{
|
||||
res, err := net.LookupMX(q)
|
||||
spew.Fprintf(w, "LookupMX(%v):\nResult: %#v\nError: %v\n\n", q, res, err)
|
||||
}
|
||||
fmt.Fprintf(w, `</pre>
|
||||
</body>
|
||||
</html>`)
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: explorer
|
||||
spec:
|
||||
containers:
|
||||
- name: explorer
|
||||
image: k8s.gcr.io/explorer:1.0
|
||||
args: ["-port=8080"]
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
protocol: TCP
|
||||
volumeMounts:
|
||||
- mountPath: "/mount/test-volume"
|
||||
name: test-volume
|
||||
volumes:
|
||||
- name: test-volume
|
||||
emptyDir: {}
|
|
@ -1 +0,0 @@
|
|||
guestbook_bin
|
|
@ -1,36 +0,0 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "guestbook-go",
|
||||
embed = [":go_default_library"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["main.go"],
|
||||
importpath = "k8s.io/kubernetes/examples/guestbook-go",
|
||||
deps = [
|
||||
"//vendor/github.com/codegangsta/negroni:go_default_library",
|
||||
"//vendor/github.com/gorilla/mux:go_default_library",
|
||||
"//vendor/github.com/xyproto/simpleredis:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
|
@ -1,24 +0,0 @@
|
|||
# Copyright 2016 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM busybox:ubuntu-14.04
|
||||
|
||||
ADD ./guestbook_bin /app/guestbook
|
||||
ADD ./public/index.html /app/public/index.html
|
||||
ADD ./public/script.js /app/public/script.js
|
||||
ADD ./public/style.css /app/public/style.css
|
||||
|
||||
WORKDIR /app
|
||||
CMD ["./guestbook"]
|
||||
EXPOSE 3000
|
|
@ -1,41 +0,0 @@
|
|||
# Copyright 2016 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Build the guestbook-go example
|
||||
|
||||
# Usage:
|
||||
# [VERSION=v3] [REGISTRY="staging-k8s.gcr.io"] make build
|
||||
VERSION?=v3
|
||||
REGISTRY?=staging-k8s.gcr.io
|
||||
|
||||
release: clean build push clean
|
||||
|
||||
# builds a docker image that builds the app and packages it into a minimal docker image
|
||||
build:
|
||||
@cp ../../bazel-bin/examples/guestbook-go/guestbook-go guestbook_bin
|
||||
docker build --pull --rm --force-rm -t ${REGISTRY}/guestbook-builder .
|
||||
docker run --rm ${REGISTRY}/guestbook-builder | docker build --pull -t "${REGISTRY}/guestbook:${VERSION}" -
|
||||
|
||||
# push the image to an registry
|
||||
push:
|
||||
gcloud docker -- push ${REGISTRY}/guestbook:${VERSION}
|
||||
|
||||
# remove previous images and containers
|
||||
clean:
|
||||
rm -f guestbook_bin
|
||||
docker rm -f ${REGISTRY}/guestbook-builder 2> /dev/null || true
|
||||
docker rmi -f ${REGISTRY}/guestbook-builder || true
|
||||
docker rmi -f "${REGISTRY}/guestbook:${VERSION}" || true
|
||||
|
||||
.PHONY: release clean build push
|
|
@ -1 +0,0 @@
|
|||
This file has moved to [https://github.com/kubernetes/examples/blob/master/guestbook-go/README.md](https://github.com/kubernetes/examples/blob/master/guestbook-go/README.md)
|
|
@ -1,37 +0,0 @@
|
|||
{
|
||||
"kind":"ReplicationController",
|
||||
"apiVersion":"v1",
|
||||
"metadata":{
|
||||
"name":"guestbook",
|
||||
"labels":{
|
||||
"app":"guestbook"
|
||||
}
|
||||
},
|
||||
"spec":{
|
||||
"replicas":3,
|
||||
"selector":{
|
||||
"app":"guestbook"
|
||||
},
|
||||
"template":{
|
||||
"metadata":{
|
||||
"labels":{
|
||||
"app":"guestbook"
|
||||
}
|
||||
},
|
||||
"spec":{
|
||||
"containers":[
|
||||
{
|
||||
"name":"guestbook",
|
||||
"image":"k8s.gcr.io/guestbook:v3",
|
||||
"ports":[
|
||||
{
|
||||
"name":"http-server",
|
||||
"containerPort":3000
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 39 KiB |
|
@ -1,22 +0,0 @@
|
|||
{
|
||||
"kind":"Service",
|
||||
"apiVersion":"v1",
|
||||
"metadata":{
|
||||
"name":"guestbook",
|
||||
"labels":{
|
||||
"app":"guestbook"
|
||||
}
|
||||
},
|
||||
"spec":{
|
||||
"ports": [
|
||||
{
|
||||
"port":3000,
|
||||
"targetPort":"http-server"
|
||||
}
|
||||
],
|
||||
"selector":{
|
||||
"app":"guestbook"
|
||||
},
|
||||
"type": "LoadBalancer"
|
||||
}
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
Copyright 2014 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/codegangsta/negroni"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/xyproto/simpleredis"
|
||||
)
|
||||
|
||||
var (
|
||||
masterPool *simpleredis.ConnectionPool
|
||||
slavePool *simpleredis.ConnectionPool
|
||||
)
|
||||
|
||||
func ListRangeHandler(rw http.ResponseWriter, req *http.Request) {
|
||||
key := mux.Vars(req)["key"]
|
||||
list := simpleredis.NewList(slavePool, key)
|
||||
members := HandleError(list.GetAll()).([]string)
|
||||
membersJSON := HandleError(json.MarshalIndent(members, "", " ")).([]byte)
|
||||
rw.Write(membersJSON)
|
||||
}
|
||||
|
||||
func ListPushHandler(rw http.ResponseWriter, req *http.Request) {
|
||||
key := mux.Vars(req)["key"]
|
||||
value := mux.Vars(req)["value"]
|
||||
list := simpleredis.NewList(masterPool, key)
|
||||
HandleError(nil, list.Add(value))
|
||||
ListRangeHandler(rw, req)
|
||||
}
|
||||
|
||||
func InfoHandler(rw http.ResponseWriter, req *http.Request) {
|
||||
info := HandleError(masterPool.Get(0).Do("INFO")).([]byte)
|
||||
rw.Write(info)
|
||||
}
|
||||
|
||||
func EnvHandler(rw http.ResponseWriter, req *http.Request) {
|
||||
environment := make(map[string]string)
|
||||
for _, item := range os.Environ() {
|
||||
splits := strings.Split(item, "=")
|
||||
key := splits[0]
|
||||
val := strings.Join(splits[1:], "=")
|
||||
environment[key] = val
|
||||
}
|
||||
|
||||
envJSON := HandleError(json.MarshalIndent(environment, "", " ")).([]byte)
|
||||
rw.Write(envJSON)
|
||||
}
|
||||
|
||||
func HandleError(result interface{}, err error) (r interface{}) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func main() {
|
||||
masterPool = simpleredis.NewConnectionPoolHost("redis-master:6379")
|
||||
defer masterPool.Close()
|
||||
slavePool = simpleredis.NewConnectionPoolHost("redis-slave:6379")
|
||||
defer slavePool.Close()
|
||||
|
||||
r := mux.NewRouter()
|
||||
r.Path("/lrange/{key}").Methods("GET").HandlerFunc(ListRangeHandler)
|
||||
r.Path("/rpush/{key}/{value}").Methods("GET").HandlerFunc(ListPushHandler)
|
||||
r.Path("/info").Methods("GET").HandlerFunc(InfoHandler)
|
||||
r.Path("/env").Methods("GET").HandlerFunc(EnvHandler)
|
||||
|
||||
n := negroni.Classic()
|
||||
n.UseHandler(r)
|
||||
n.Run(":3000")
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<meta charset="utf-8">
|
||||
<meta content="width=device-width" name="viewport">
|
||||
<link href="style.css" rel="stylesheet">
|
||||
<title>Guestbook</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="header">
|
||||
<h1>Guestbook</h1>
|
||||
</div>
|
||||
|
||||
<div id="guestbook-entries">
|
||||
<p>Waiting for database connection...</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<form id="guestbook-form">
|
||||
<input autocomplete="off" id="guestbook-entry-content" type="text">
|
||||
<a href="#" id="guestbook-submit">Submit</a>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p><h2 id="guestbook-host-address"></h2></p>
|
||||
<p><a href="env">/env</a>
|
||||
<a href="info">/info</a></p>
|
||||
</div>
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
|
||||
<script src="script.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,46 +0,0 @@
|
|||
$(document).ready(function() {
|
||||
var headerTitleElement = $("#header h1");
|
||||
var entriesElement = $("#guestbook-entries");
|
||||
var formElement = $("#guestbook-form");
|
||||
var submitElement = $("#guestbook-submit");
|
||||
var entryContentElement = $("#guestbook-entry-content");
|
||||
var hostAddressElement = $("#guestbook-host-address");
|
||||
|
||||
var appendGuestbookEntries = function(data) {
|
||||
entriesElement.empty();
|
||||
$.each(data, function(key, val) {
|
||||
entriesElement.append("<p>" + val + "</p>");
|
||||
});
|
||||
}
|
||||
|
||||
var handleSubmission = function(e) {
|
||||
e.preventDefault();
|
||||
var entryValue = entryContentElement.val()
|
||||
if (entryValue.length > 0) {
|
||||
entriesElement.append("<p>...</p>");
|
||||
$.getJSON("rpush/guestbook/" + entryValue, appendGuestbookEntries);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// colors = purple, blue, red, green, yellow
|
||||
var colors = ["#549", "#18d", "#d31", "#2a4", "#db1"];
|
||||
var randomColor = colors[Math.floor(5 * Math.random())];
|
||||
(function setElementsColor(color) {
|
||||
headerTitleElement.css("color", color);
|
||||
entryContentElement.css("box-shadow", "inset 0 0 0 2px " + color);
|
||||
submitElement.css("background-color", color);
|
||||
})(randomColor);
|
||||
|
||||
submitElement.click(handleSubmission);
|
||||
formElement.submit(handleSubmission);
|
||||
hostAddressElement.append(document.URL);
|
||||
|
||||
// Poll every second.
|
||||
(function fetchGuestbook() {
|
||||
$.getJSON("lrange/guestbook").done(appendGuestbookEntries).always(
|
||||
function() {
|
||||
setTimeout(fetchGuestbook, 1000);
|
||||
});
|
||||
})();
|
||||
});
|
|
@ -1,61 +0,0 @@
|
|||
body, input {
|
||||
color: #123;
|
||||
font-family: "Gill Sans", sans-serif;
|
||||
}
|
||||
|
||||
div {
|
||||
overflow: hidden;
|
||||
padding: 1em 0;
|
||||
position: relative;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h1, h2, p, input, a {
|
||||
font-weight: 300;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #BDB76B;
|
||||
font-size: 3.5em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
form {
|
||||
margin: 0 auto;
|
||||
max-width: 50em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
input {
|
||||
border: 0;
|
||||
border-radius: 1000px;
|
||||
box-shadow: inset 0 0 0 2px #BDB76B;
|
||||
display: inline;
|
||||
font-size: 1.5em;
|
||||
margin-bottom: 1em;
|
||||
outline: none;
|
||||
padding: .5em 5%;
|
||||
width: 55%;
|
||||
}
|
||||
|
||||
form a {
|
||||
background: #BDB76B;
|
||||
border: 0;
|
||||
border-radius: 1000px;
|
||||
color: #FFF;
|
||||
font-size: 1.25em;
|
||||
font-weight: 400;
|
||||
padding: .75em 2em;
|
||||
text-decoration: none;
|
||||
text-transform: uppercase;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 1.5em;
|
||||
line-height: 1.5;
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
{
|
||||
"kind":"ReplicationController",
|
||||
"apiVersion":"v1",
|
||||
"metadata":{
|
||||
"name":"redis-master",
|
||||
"labels":{
|
||||
"app":"redis",
|
||||
"role":"master"
|
||||
}
|
||||
},
|
||||
"spec":{
|
||||
"replicas":1,
|
||||
"selector":{
|
||||
"app":"redis",
|
||||
"role":"master"
|
||||
},
|
||||
"template":{
|
||||
"metadata":{
|
||||
"labels":{
|
||||
"app":"redis",
|
||||
"role":"master"
|
||||
}
|
||||
},
|
||||
"spec":{
|
||||
"containers":[
|
||||
{
|
||||
"name":"redis-master",
|
||||
"image":"redis:2.8.23",
|
||||
"ports":[
|
||||
{
|
||||
"name":"redis-server",
|
||||
"containerPort":6379
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
{
|
||||
"kind":"Service",
|
||||
"apiVersion":"v1",
|
||||
"metadata":{
|
||||
"name":"redis-master",
|
||||
"labels":{
|
||||
"app":"redis",
|
||||
"role":"master"
|
||||
}
|
||||
},
|
||||
"spec":{
|
||||
"ports": [
|
||||
{
|
||||
"port":6379,
|
||||
"targetPort":"redis-server"
|
||||
}
|
||||
],
|
||||
"selector":{
|
||||
"app":"redis",
|
||||
"role":"master"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
{
|
||||
"kind":"ReplicationController",
|
||||
"apiVersion":"v1",
|
||||
"metadata":{
|
||||
"name":"redis-slave",
|
||||
"labels":{
|
||||
"app":"redis",
|
||||
"role":"slave"
|
||||
}
|
||||
},
|
||||
"spec":{
|
||||
"replicas":2,
|
||||
"selector":{
|
||||
"app":"redis",
|
||||
"role":"slave"
|
||||
},
|
||||
"template":{
|
||||
"metadata":{
|
||||
"labels":{
|
||||
"app":"redis",
|
||||
"role":"slave"
|
||||
}
|
||||
},
|
||||
"spec":{
|
||||
"containers":[
|
||||
{
|
||||
"name":"redis-slave",
|
||||
"image":"kubernetes/redis-slave:v2",
|
||||
"ports":[
|
||||
{
|
||||
"name":"redis-server",
|
||||
"containerPort":6379
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
{
|
||||
"kind":"Service",
|
||||
"apiVersion":"v1",
|
||||
"metadata":{
|
||||
"name":"redis-slave",
|
||||
"labels":{
|
||||
"app":"redis",
|
||||
"role":"slave"
|
||||
}
|
||||
},
|
||||
"spec":{
|
||||
"ports": [
|
||||
{
|
||||
"port":6379,
|
||||
"targetPort":"redis-server"
|
||||
}
|
||||
],
|
||||
"selector":{
|
||||
"app":"redis",
|
||||
"role":"slave"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
This file has moved to [https://github.com/kubernetes/examples/blob/master/guestbook/README.md](https://github.com/kubernetes/examples/blob/master/guestbook/README.md)
|
|
@ -1,46 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: frontend
|
||||
labels:
|
||||
app: guestbook
|
||||
tier: frontend
|
||||
spec:
|
||||
# if your cluster supports it, uncomment the following to automatically create
|
||||
# an external load-balanced IP for the frontend service.
|
||||
# type: LoadBalancer
|
||||
ports:
|
||||
- port: 80
|
||||
selector:
|
||||
app: guestbook
|
||||
tier: frontend
|
||||
---
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: frontend
|
||||
spec:
|
||||
replicas: 3
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: guestbook
|
||||
tier: frontend
|
||||
spec:
|
||||
containers:
|
||||
- name: php-redis
|
||||
image: gcr.io/google-samples/gb-frontend:v4
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 100Mi
|
||||
env:
|
||||
- name: GET_HOSTS_FROM
|
||||
value: dns
|
||||
# If your cluster config does not include a dns service, then to
|
||||
# instead access environment variables to find service host
|
||||
# info, comment out the 'value: dns' line above, and uncomment the
|
||||
# line below:
|
||||
# value: env
|
||||
ports:
|
||||
- containerPort: 80
|
|
@ -1,133 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: redis-master
|
||||
labels:
|
||||
app: redis
|
||||
tier: backend
|
||||
role: master
|
||||
spec:
|
||||
ports:
|
||||
- port: 6379
|
||||
targetPort: 6379
|
||||
selector:
|
||||
app: redis
|
||||
tier: backend
|
||||
role: master
|
||||
---
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: redis-master
|
||||
spec:
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: redis
|
||||
role: master
|
||||
tier: backend
|
||||
spec:
|
||||
containers:
|
||||
- name: master
|
||||
image: k8s.gcr.io/redis:e2e # or just image: redis
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 100Mi
|
||||
ports:
|
||||
- containerPort: 6379
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: redis-slave
|
||||
labels:
|
||||
app: redis
|
||||
tier: backend
|
||||
role: slave
|
||||
spec:
|
||||
ports:
|
||||
- port: 6379
|
||||
selector:
|
||||
app: redis
|
||||
tier: backend
|
||||
role: slave
|
||||
---
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: redis-slave
|
||||
spec:
|
||||
replicas: 2
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: redis
|
||||
role: slave
|
||||
tier: backend
|
||||
spec:
|
||||
containers:
|
||||
- name: slave
|
||||
image: gcr.io/google_samples/gb-redisslave:v1
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 100Mi
|
||||
env:
|
||||
- name: GET_HOSTS_FROM
|
||||
value: dns
|
||||
# If your cluster config does not include a dns service, then to
|
||||
# instead access an environment variable to find the master
|
||||
# service's host, comment out the 'value: dns' line above, and
|
||||
# uncomment the line below:
|
||||
# value: env
|
||||
ports:
|
||||
- containerPort: 6379
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: frontend
|
||||
labels:
|
||||
app: guestbook
|
||||
tier: frontend
|
||||
spec:
|
||||
# if your cluster supports it, uncomment the following to automatically create
|
||||
# an external load-balanced IP for the frontend service.
|
||||
# type: LoadBalancer
|
||||
ports:
|
||||
- port: 80
|
||||
selector:
|
||||
app: guestbook
|
||||
tier: frontend
|
||||
---
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: frontend
|
||||
spec:
|
||||
replicas: 3
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: guestbook
|
||||
tier: frontend
|
||||
spec:
|
||||
containers:
|
||||
- name: php-redis
|
||||
image: gcr.io/google-samples/gb-frontend:v4
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 100Mi
|
||||
env:
|
||||
- name: GET_HOSTS_FROM
|
||||
value: dns
|
||||
# If your cluster config does not include a dns service, then to
|
||||
# instead access environment variables to find service host
|
||||
# info, comment out the 'value: dns' line above, and uncomment the
|
||||
# line below:
|
||||
# value: env
|
||||
ports:
|
||||
- containerPort: 80
|
|
@ -1,46 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: redis-slave
|
||||
labels:
|
||||
app: redis
|
||||
role: slave
|
||||
tier: backend
|
||||
spec:
|
||||
ports:
|
||||
- port: 6379
|
||||
selector:
|
||||
app: redis
|
||||
role: slave
|
||||
tier: backend
|
||||
---
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: redis-slave
|
||||
spec:
|
||||
replicas: 2
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: redis
|
||||
role: slave
|
||||
tier: backend
|
||||
spec:
|
||||
containers:
|
||||
- name: slave
|
||||
image: gcr.io/google_samples/gb-redisslave:v1
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 100Mi
|
||||
env:
|
||||
- name: GET_HOSTS_FROM
|
||||
value: dns
|
||||
# If your cluster config does not include a dns service, then to
|
||||
# instead access an environment variable to find the master
|
||||
# service's host, comment out the 'value: dns' line above, and
|
||||
# uncomment the line below:
|
||||
# value: env
|
||||
ports:
|
||||
- containerPort: 6379
|
|
@ -1,29 +0,0 @@
|
|||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: frontend
|
||||
spec:
|
||||
replicas: 3
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: guestbook
|
||||
tier: frontend
|
||||
spec:
|
||||
containers:
|
||||
- name: php-redis
|
||||
image: gcr.io/google-samples/gb-frontend:v4
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 100Mi
|
||||
env:
|
||||
- name: GET_HOSTS_FROM
|
||||
value: dns
|
||||
# If your cluster config does not include a dns service, then to
|
||||
# instead access environment variables to find service host
|
||||
# info, comment out the 'value: dns' line above, and uncomment the
|
||||
# line below:
|
||||
# value: env
|
||||
ports:
|
||||
- containerPort: 80
|
|
@ -1,16 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: frontend
|
||||
labels:
|
||||
app: guestbook
|
||||
tier: frontend
|
||||
spec:
|
||||
# if your cluster supports it, uncomment the following to automatically create
|
||||
# an external load-balanced IP for the frontend service.
|
||||
# type: LoadBalancer
|
||||
ports:
|
||||
- port: 80
|
||||
selector:
|
||||
app: guestbook
|
||||
tier: frontend
|
|
@ -1,31 +0,0 @@
|
|||
# Copyright 2016 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM php:5-apache
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y php-pear
|
||||
RUN pear channel-discover pear.nrk.io
|
||||
RUN pear install nrk/Predis
|
||||
|
||||
# If the container's stdio is connected to systemd-journald,
|
||||
# /proc/self/fd/{1,2} are Unix sockets and apache will not be able to open()
|
||||
# them. Use "cat" to write directly to the already opened fds without opening
|
||||
# them again.
|
||||
RUN sed -i 's#ErrorLog /proc/self/fd/2#ErrorLog "|$/bin/cat 1>\&2"#' /etc/apache2/apache2.conf
|
||||
RUN sed -i 's#CustomLog /proc/self/fd/1 combined#CustomLog "|/bin/cat" combined#' /etc/apache2/apache2.conf
|
||||
|
||||
ADD guestbook.php /var/www/html/guestbook.php
|
||||
ADD controllers.js /var/www/html/controllers.js
|
||||
ADD index.html /var/www/html/index.html
|
|
@ -1,29 +0,0 @@
|
|||
var redisApp = angular.module('redis', ['ui.bootstrap']);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function RedisController() {}
|
||||
|
||||
RedisController.prototype.onRedis = function() {
|
||||
this.scope_.messages.push(this.scope_.msg);
|
||||
this.scope_.msg = "";
|
||||
var value = this.scope_.messages.join();
|
||||
this.http_.get("guestbook.php?cmd=set&key=messages&value=" + value)
|
||||
.success(angular.bind(this, function(data) {
|
||||
this.scope_.redisResponse = "Updated.";
|
||||
}));
|
||||
};
|
||||
|
||||
redisApp.controller('RedisCtrl', function ($scope, $http, $location) {
|
||||
$scope.controller = new RedisController();
|
||||
$scope.controller.scope_ = $scope;
|
||||
$scope.controller.location_ = $location;
|
||||
$scope.controller.http_ = $http;
|
||||
|
||||
$scope.controller.http_.get("guestbook.php?cmd=get&key=messages")
|
||||
.success(function(data) {
|
||||
console.log(data);
|
||||
$scope.messages = data.data.split(",");
|
||||
});
|
||||
});
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
require 'Predis/Autoloader.php';
|
||||
|
||||
Predis\Autoloader::register();
|
||||
|
||||
if (isset($_GET['cmd']) === true) {
|
||||
$host = 'redis-master';
|
||||
if (getenv('GET_HOSTS_FROM') == 'env') {
|
||||
$host = getenv('REDIS_MASTER_SERVICE_HOST');
|
||||
}
|
||||
header('Content-Type: application/json');
|
||||
if ($_GET['cmd'] == 'set') {
|
||||
$client = new Predis\Client([
|
||||
'scheme' => 'tcp',
|
||||
'host' => $host,
|
||||
'port' => 6379,
|
||||
]);
|
||||
|
||||
$client->set($_GET['key'], $_GET['value']);
|
||||
print('{"message": "Updated"}');
|
||||
} else {
|
||||
$host = 'redis-slave';
|
||||
if (getenv('GET_HOSTS_FROM') == 'env') {
|
||||
$host = getenv('REDIS_SLAVE_SERVICE_HOST');
|
||||
}
|
||||
$client = new Predis\Client([
|
||||
'scheme' => 'tcp',
|
||||
'host' => $host,
|
||||
'port' => 6379,
|
||||
]);
|
||||
|
||||
$value = $client->get($_GET['key']);
|
||||
print('{"data": "' . $value . '"}');
|
||||
}
|
||||
} else {
|
||||
phpinfo();
|
||||
} ?>
|
|
@ -1,25 +0,0 @@
|
|||
<html ng-app="redis">
|
||||
<head>
|
||||
<title>Guestbook</title>
|
||||
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.12/angular.min.js"></script>
|
||||
<script src="controllers.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.13.0/ui-bootstrap-tpls.js"></script>
|
||||
</head>
|
||||
<body ng-controller="RedisCtrl">
|
||||
<div style="width: 50%; margin-left: 20px">
|
||||
<h2>Guestbook</h2>
|
||||
<form>
|
||||
<fieldset>
|
||||
<input ng-model="msg" placeholder="Messages" class="form-control" type="text" name="input"><br>
|
||||
<button type="button" class="btn btn-primary" ng-click="controller.onRedis()">Submit</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
<div>
|
||||
<div ng-repeat="msg in messages track by $index">
|
||||
{{msg}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,22 +0,0 @@
|
|||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: redis-master
|
||||
spec:
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: redis
|
||||
role: master
|
||||
tier: backend
|
||||
spec:
|
||||
containers:
|
||||
- name: master
|
||||
image: k8s.gcr.io/redis:e2e # or just image: redis
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 100Mi
|
||||
ports:
|
||||
- containerPort: 6379
|
|
@ -1,16 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: redis-master
|
||||
labels:
|
||||
app: redis
|
||||
role: master
|
||||
tier: backend
|
||||
spec:
|
||||
ports:
|
||||
- port: 6379
|
||||
targetPort: 6379
|
||||
selector:
|
||||
app: redis
|
||||
role: master
|
||||
tier: backend
|
|
@ -1,30 +0,0 @@
|
|||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: redis-slave
|
||||
spec:
|
||||
replicas: 2
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: redis
|
||||
role: slave
|
||||
tier: backend
|
||||
spec:
|
||||
containers:
|
||||
- name: slave
|
||||
image: gcr.io/google_samples/gb-redisslave:v1
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 100Mi
|
||||
env:
|
||||
- name: GET_HOSTS_FROM
|
||||
value: dns
|
||||
# If your cluster config does not include a dns service, then to
|
||||
# instead access an environment variable to find the master
|
||||
# service's host, comment out the 'value: dns' line above, and
|
||||
# uncomment the line below:
|
||||
# value: env
|
||||
ports:
|
||||
- containerPort: 6379
|
|
@ -1,15 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: redis-slave
|
||||
labels:
|
||||
app: redis
|
||||
role: slave
|
||||
tier: backend
|
||||
spec:
|
||||
ports:
|
||||
- port: 6379
|
||||
selector:
|
||||
app: redis
|
||||
role: slave
|
||||
tier: backend
|
|
@ -1,21 +0,0 @@
|
|||
# Copyright 2016 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM redis
|
||||
|
||||
ADD run.sh /run.sh
|
||||
|
||||
RUN chmod a+x /run.sh
|
||||
|
||||
CMD /run.sh
|
|
@ -1,21 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright 2014 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
if [[ ${GET_HOSTS_FROM:-dns} == "env" ]]; then
|
||||
redis-server --slaveof ${REDIS_MASTER_SERVICE_HOST} 6379
|
||||
else
|
||||
redis-server --slaveof redis-master 6379
|
||||
fi
|
|
@ -1,88 +0,0 @@
|
|||
# Example Guidelines
|
||||
|
||||
## An Example Is
|
||||
|
||||
An example demonstrates running an application/framework/workload on
|
||||
Kubernetes in a meaningful way. It is educational and informative.
|
||||
|
||||
Examples are not:
|
||||
|
||||
* Full app deployments, ready to use, with no explanation. These
|
||||
belong to [Helm charts](https://github.com/kubernetes/charts).
|
||||
* Simple toys to show how to use a Kubernetes feature. These belong in
|
||||
the [user guide](https://kubernetes.io/docs/user-guide/).
|
||||
* Demos that follow a script to show a Kubernetes feature in
|
||||
action. Example: killing a node to demonstrate controller
|
||||
self-healing.
|
||||
* A tutorial which guides the user through multiple progressively more
|
||||
complex deployments to arrive at the final solution. An example
|
||||
should just demonstrate how to setup the correct deployment
|
||||
|
||||
## An Example Includes
|
||||
|
||||
### Up front
|
||||
|
||||
* Has a "this is what you'll learn" section.
|
||||
* Has a Table of Contents.
|
||||
* Has a section that brings up the app in the fewest number of
|
||||
commands (TL;DR / quickstart), without cloning the repo (kubectl
|
||||
apply -f http://...).
|
||||
* Points to documentation of prerequisites.
|
||||
* [Create a cluster](https://kubernetes.io/docs/getting-started-guides/) (e.g., single-node docker).
|
||||
* [Setup kubectl](https://kubernetes.io/docs/user-guide/prereqs.md).
|
||||
* etc.
|
||||
* Should specify which release of Kubernetes is required and any other
|
||||
prerequisites, such as DNS, a cloudprovider with PV provisioning, a
|
||||
cloudprovider with external load balancers, etc.
|
||||
* Point to general documentation about alternatives for those
|
||||
mechanisms rather than present the alternatives in each example.
|
||||
* Tries to balance between using using new features, and being
|
||||
compatible across environments.
|
||||
|
||||
### Throughout
|
||||
|
||||
* Should point to documentation on first mention:
|
||||
[kubectl](https://kubernetes.io/docs/user-guide/kubectl-overview.md),
|
||||
[pods](https://kubernetes.io/docs/user-guide/pods.md),
|
||||
[services](https://kubernetes.io/docs/user-guide/services.md),
|
||||
[deployments](https://kubernetes.io/docs/user-guide/deployments.md),
|
||||
[replication controllers](https://kubernetes.io/docs/user-guide/replication-controller.md),
|
||||
[jobs](https://kubernetes.io/docs/user-guide/jobs.md),
|
||||
[labels](https://kubernetes.io/docs/user-guide/labels.md),
|
||||
[persistent volumes](https://kubernetes.io/docs/user-guide/persistent-volumes.md),
|
||||
etc.
|
||||
* Most examples should be cloudprovider-independent (e.g., using PVCs, not PDs).
|
||||
* Other examples with cloudprovider-specific bits could be somewhere else.
|
||||
* Actually show the app working -- console output, and or screenshots.
|
||||
* Ascii animations and screencasts are recommended.
|
||||
* Follows [config best practices](https://kubernetes.io/docs/user-guide/config-best-practices.md).
|
||||
* Shouldn't duplicate the [thorough walk-through](https://kubernetes.io/docs/user-guide/#thorough-walkthrough).
|
||||
* Docker images are pre-built, and source is contained in a subfolder.
|
||||
* Source is the Dockerfile and any custom files needed beyond the
|
||||
upstream app being packaged.
|
||||
* Images are pushed to `gcr.io/google-samples`. Contact @jeffmendoza
|
||||
to have an image pushed
|
||||
* Images are tagged with a version (not latest) that is referenced
|
||||
in the example config.
|
||||
* Only use the code highlighting types
|
||||
[supported by Rouge](https://github.com/jneen/rouge/wiki/list-of-supported-languages-and-lexers),
|
||||
as this is what GitHub Pages uses.
|
||||
* Commands to be copied use the `shell` syntax highlighting type, and
|
||||
do not include any kind of prompt.
|
||||
* Example output is in a separate block quote to distinguish it from
|
||||
the command (which doesn't have a prompt).
|
||||
* When providing an example command or config for which the user is
|
||||
expected to substitute text with something specific to them, use
|
||||
angle brackets: `<IDENTIFIER>` for the text to be substituted.
|
||||
* Use `kubectl` instead of `cluster\kubectl.sh` for example cli
|
||||
commands.
|
||||
|
||||
### At the end
|
||||
|
||||
* Should have a section suggesting what to look at next, both in terms
|
||||
of "additional resources" and "what example to look at next".
|
||||
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/examples/guidelines.md?pixel)]()
|
||||
<!-- END MUNGE: GENERATED_ANALYTICS -->
|
|
@ -1,38 +0,0 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "https-nginx",
|
||||
embed = [":go_default_library"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["make_secret.go"],
|
||||
importpath = "k8s.io/kubernetes/examples/https-nginx",
|
||||
deps = [
|
||||
"//pkg/api/legacyscheme:go_default_library",
|
||||
"//pkg/apis/core:go_default_library",
|
||||
"//pkg/apis/core/install:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
|
@ -1,24 +0,0 @@
|
|||
# Copyright 2016 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM nginx
|
||||
|
||||
|
||||
COPY index2.html /usr/share/nginx/html/index2.html
|
||||
RUN chmod +r /usr/share/nginx/html/index2.html
|
||||
COPY auto-reload-nginx.sh /home/auto-reload-nginx.sh
|
||||
RUN chmod +x /home/auto-reload-nginx.sh
|
||||
|
||||
# install inotify
|
||||
RUN apt-get update && apt-get install -y inotify-tools
|
|
@ -1,38 +0,0 @@
|
|||
# Copyright 2016 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
all:
|
||||
|
||||
TAG = 1.0
|
||||
PREFIX = bprashanth/nginxhttps
|
||||
KEY = /tmp/nginx.key
|
||||
CERT = /tmp/nginx.crt
|
||||
SECRET = /tmp/secret.json
|
||||
|
||||
keys:
|
||||
# The CName used here is specific to the service specified in nginx-app.yaml.
|
||||
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout $(KEY) -out $(CERT) -subj "/CN=nginxsvc/O=nginxsvc"
|
||||
|
||||
secret:
|
||||
go run make_secret.go -crt $(CERT) -key $(KEY) > $(SECRET)
|
||||
|
||||
container:
|
||||
docker build --pull -t $(PREFIX):$(TAG) .
|
||||
|
||||
push: container
|
||||
docker push $(PREFIX):$(TAG)
|
||||
|
||||
clean:
|
||||
rm $(KEY)
|
||||
rm $(CERT)
|
|
@ -1 +0,0 @@
|
|||
This file has moved to [https://github.com/kubernetes/examples/blob/master/staging/https-nginx/README.md](https://github.com/kubernetes/examples/blob/master/staging/https-nginx/README.md)
|
|
@ -1,30 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Copyright 2016 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
nginx "$@"
|
||||
oldcksum=`cksum /etc/nginx/conf.d/default.conf`
|
||||
|
||||
inotifywait -e modify,move,create,delete -mr --timefmt '%d/%m/%y %H:%M' --format '%T' \
|
||||
/etc/nginx/conf.d/ | while read date time; do
|
||||
|
||||
newcksum=`cksum /etc/nginx/conf.d/default.conf`
|
||||
if [ "$newcksum" != "$oldcksum" ]; then
|
||||
echo "At ${time} on ${date}, config file update detected."
|
||||
oldcksum=$newcksum
|
||||
nginx -s reload
|
||||
fi
|
||||
|
||||
done
|
|
@ -1,17 +0,0 @@
|
|||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server ipv6only=on;
|
||||
|
||||
listen 443 ssl;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
server_name localhost;
|
||||
ssl_certificate /etc/nginx/ssl/nginx.crt;
|
||||
ssl_certificate_key /etc/nginx/ssl/nginx.key;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Nginx reloaded!</title>
|
||||
<style>
|
||||
body {
|
||||
width: 35em;
|
||||
margin: 0 auto;
|
||||
font-family: Tahoma, Verdana, Arial, sans-serif;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Nginx has been reloaded!</h1>
|
||||
<p>If you see this page, the nginx web server has been automatically reloaded, since the config file has been updated using <a href="https://github.com/kubernetes/kubernetes">Kubernetes</a>.</p>
|
||||
|
||||
|
||||
<p>For online documentation and support please refer to
|
||||
<a href="http://kubernetes.io/">kubernetes.io</a>.<br/></p>
|
||||
|
||||
<p>For online documentation and support please refer to
|
||||
<a href="http://nginx.org/">nginx.org</a>.<br/>
|
||||
Commercial support is available at
|
||||
<a href="http://nginx.com/">nginx.com</a>.</p>
|
||||
|
||||
<p><em>Thank you for using nginx.</em></p>
|
||||
</body>
|
||||
</html>
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// A small script that converts the given open ssl public/private keys to
|
||||
// a secret that it writes to stdout as json. Most common use case is to
|
||||
// create a secret from self signed certificates used to authenticate with
|
||||
// a devserver. Usage: go run make_secret.go -crt ca.crt -key priv.key > secret.json
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
|
||||
// This installs the legacy v1 API
|
||||
_ "k8s.io/kubernetes/pkg/apis/core/install"
|
||||
)
|
||||
|
||||
// TODO:
|
||||
// Add a -o flag that writes to the specified destination file.
|
||||
// Teach the script to create crt and key if -crt and -key aren't specified.
|
||||
var (
|
||||
crt = flag.String("crt", "", "path to nginx certificates.")
|
||||
key = flag.String("key", "", "path to nginx private key.")
|
||||
)
|
||||
|
||||
func read(file string) []byte {
|
||||
b, err := ioutil.ReadFile(file)
|
||||
if err != nil {
|
||||
log.Fatalf("Cannot read file %v, %v", file, err)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
if *crt == "" || *key == "" {
|
||||
log.Fatalf("Need to specify -crt -key and -template")
|
||||
}
|
||||
nginxCrt := read(*crt)
|
||||
nginxKey := read(*key)
|
||||
secret := &api.Secret{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "nginxsecret",
|
||||
},
|
||||
Data: map[string][]byte{
|
||||
"nginx.crt": nginxCrt,
|
||||
"nginx.key": nginxKey,
|
||||
},
|
||||
}
|
||||
fmt.Printf(runtime.EncodeOrDie(legacyscheme.Codecs.LegacyCodec(legacyscheme.Registry.EnabledVersions()...), secret))
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: nginxsvc
|
||||
labels:
|
||||
app: nginx
|
||||
spec:
|
||||
type: NodePort
|
||||
ports:
|
||||
- port: 80
|
||||
protocol: TCP
|
||||
name: http
|
||||
- port: 443
|
||||
protocol: TCP
|
||||
name: https
|
||||
selector:
|
||||
app: nginx
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ReplicationController
|
||||
metadata:
|
||||
name: my-nginx
|
||||
spec:
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx
|
||||
spec:
|
||||
volumes:
|
||||
- name: secret-volume
|
||||
secret:
|
||||
secretName: nginxsecret
|
||||
- name: configmap-volume
|
||||
configMap:
|
||||
name: nginxconfigmap
|
||||
containers:
|
||||
- name: nginxhttps
|
||||
image: ymqytw/nginxhttps:1.5
|
||||
command: ["/home/auto-reload-nginx.sh"]
|
||||
ports:
|
||||
- containerPort: 443
|
||||
- containerPort: 80
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /index.html
|
||||
port: 80
|
||||
initialDelaySeconds: 30
|
||||
timeoutSeconds: 1
|
||||
volumeMounts:
|
||||
- mountPath: /etc/nginx/ssl
|
||||
name: secret-volume
|
||||
- mountPath: /etc/nginx/conf.d
|
||||
name: configmap-volume
|
|
@ -1 +0,0 @@
|
|||
This file has moved to [https://github.com/kubernetes/examples/blob/master/staging/javaee/README.md](https://github.com/kubernetes/examples/blob/master/staging/javaee/README.md)
|
|
@ -1,28 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: mysql-pod
|
||||
labels:
|
||||
name: mysql-pod
|
||||
context: docker-k8s-lab
|
||||
spec:
|
||||
containers:
|
||||
-
|
||||
name: mysql
|
||||
image: mysql:latest
|
||||
env:
|
||||
-
|
||||
name: "MYSQL_USER"
|
||||
value: "mysql"
|
||||
-
|
||||
name: "MYSQL_PASSWORD"
|
||||
value: "mysql"
|
||||
-
|
||||
name: "MYSQL_DATABASE"
|
||||
value: "sample"
|
||||
-
|
||||
name: "MYSQL_ROOT_PASSWORD"
|
||||
value: "supersecret"
|
||||
ports:
|
||||
-
|
||||
containerPort: 3306
|
|
@ -1,15 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: mysql-service
|
||||
labels:
|
||||
name: mysql-pod
|
||||
context: docker-k8s-lab
|
||||
spec:
|
||||
ports:
|
||||
# the port that this service should serve on
|
||||
- port: 3306
|
||||
# label keys and values that must match in order to receive traffic for this service
|
||||
selector:
|
||||
name: mysql-pod
|
||||
context: docker-k8s-lab
|
|
@ -1,19 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: ReplicationController
|
||||
metadata:
|
||||
name: wildfly-rc
|
||||
labels:
|
||||
name: wildfly
|
||||
context: docker-k8s-lab
|
||||
spec:
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
name: wildfly
|
||||
spec:
|
||||
containers:
|
||||
- name: wildfly-rc-pod
|
||||
image: arungupta/wildfly-mysql-javaee7:k8s
|
||||
ports:
|
||||
- containerPort: 8080
|
|
@ -1 +0,0 @@
|
|||
This file has moved to [https://github.com/kubernetes/examples/blob/master/staging/javaweb-tomcat-sidecar/README.md](https://github.com/kubernetes/examples/blob/master/staging/javaweb-tomcat-sidecar/README.md)
|
|
@ -1,31 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: javaweb-2
|
||||
spec:
|
||||
containers:
|
||||
- image: resouer/sample:v2
|
||||
name: war
|
||||
lifecycle:
|
||||
postStart:
|
||||
exec:
|
||||
command:
|
||||
- "cp"
|
||||
- "/sample.war"
|
||||
- "/app"
|
||||
volumeMounts:
|
||||
- mountPath: /app
|
||||
name: app-volume
|
||||
- image: resouer/mytomcat:7.0
|
||||
name: tomcat
|
||||
command: ["sh","-c","/root/apache-tomcat-7.0.42-v2/bin/start.sh"]
|
||||
volumeMounts:
|
||||
- mountPath: /root/apache-tomcat-7.0.42-v2/webapps
|
||||
name: app-volume
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
hostPort: 8001
|
||||
volumes:
|
||||
- name: app-volume
|
||||
emptyDir: {}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: javaweb
|
||||
spec:
|
||||
containers:
|
||||
- image: resouer/sample:v1
|
||||
name: war
|
||||
volumeMounts:
|
||||
- mountPath: /app
|
||||
name: app-volume
|
||||
- image: resouer/mytomcat:7.0
|
||||
name: tomcat
|
||||
command: ["sh","-c","/root/apache-tomcat-7.0.42-v2/bin/start.sh"]
|
||||
volumeMounts:
|
||||
- mountPath: /root/apache-tomcat-7.0.42-v2/webapps
|
||||
name: app-volume
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
hostPort: 8001
|
||||
volumes:
|
||||
- name: app-volume
|
||||
emptyDir: {}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 45 KiB |
|
@ -1 +0,0 @@
|
|||
This file has moved to [https://github.com/kubernetes/examples/blob/master/staging/job/expansions/README.md](https://github.com/kubernetes/examples/blob/master/staging/job/expansions/README.md)
|
|
@ -1 +0,0 @@
|
|||
This file has moved to [https://github.com/kubernetes/examples/blob/master/staging/job/work-queue-1/README.md](https://github.com/kubernetes/examples/blob/master/staging/job/work-queue-1/README.md)
|
|
@ -1 +0,0 @@
|
|||
This file has moved to [https://github.com/kubernetes/examples/blob/master/staging/job/work-queue-2/README.md](https://github.com/kubernetes/examples/blob/master/staging/job/work-queue-2/README.md)
|
|
@ -1,2 +0,0 @@
|
|||
kubectl
|
||||
.tag
|
|
@ -1,17 +0,0 @@
|
|||
# Copyright 2016 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM scratch
|
||||
ADD kubectl kubectl
|
||||
ENTRYPOINT ["/kubectl"]
|
|
@ -1,48 +0,0 @@
|
|||
# Copyright 2016 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Use:
|
||||
#
|
||||
# `make kubectl` will build kubectl.
|
||||
# `make tag` will suggest a tag.
|
||||
# `make container` will build a container-- you must supply a tag.
|
||||
# `make push` will push the container-- you must supply a tag.
|
||||
|
||||
GOARCH?=$(shell go env GOARCH)
|
||||
GOOS?=$(shell go env GOOS)
|
||||
|
||||
kubectl:
|
||||
make -C ../../ WHAT=cmd/kubectl KUBE_STATIC_OVERRIDES="kubectl"; \
|
||||
cp ../../_output/local/bin/$(GOOS)/$(GOARCH)/kubectl .
|
||||
|
||||
.tag: kubectl
|
||||
./kubectl version --client | grep -o 'GitVersion:"[^"]*"' | sed 's/[^"]*"\([^"+]*\).*/\1/' > .tag
|
||||
|
||||
tag: .tag
|
||||
@echo "Suggest using TAG=$(shell cat .tag)"
|
||||
@echo "$$ make container TAG=$(shell cat .tag)"
|
||||
@echo "or"
|
||||
@echo "$$ make push TAG=$(shell cat .tag)"
|
||||
|
||||
container:
|
||||
$(if $(TAG),,$(error TAG is not defined. Use 'make tag' to see a suggestion))
|
||||
docker build --pull -t staging-k8s.gcr.io/kubectl:$(TAG) .
|
||||
|
||||
push: container
|
||||
$(if $(TAG),,$(error TAG is not defined. Use 'make tag' to see a suggestion))
|
||||
gcloud docker -- push staging-k8s.gcr.io/kubectl:$(TAG)
|
||||
|
||||
clean:
|
||||
rm -f kubectl
|
||||
rm -f .tag
|
|
@ -1 +0,0 @@
|
|||
This file has moved to [https://github.com/kubernetes/examples/blob/master/staging/kubectl-container/README.md](https://github.com/kubernetes/examples/blob/master/staging/kubectl-container/README.md)
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue