Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
52e94b1e
Commit
52e94b1e
authored
May 06, 2015
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7591 from derekwaynecarr/fix_origin
Fix OpenShift example
parents
b60a90c3
a8f8e2d6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
186 additions
and
325 deletions
+186
-325
README.md
examples/openshift-origin/README.md
+98
-54
cleanup.sh
examples/openshift-origin/cleanup.sh
+8
-17
create-all.sh
examples/openshift-origin/create-all.sh
+0
-38
create.sh
examples/openshift-origin/create.sh
+34
-0
openshift-controller.yaml
examples/openshift-origin/openshift-controller.yaml
+34
-0
openshift-service.yaml
examples/openshift-origin/openshift-service.yaml
+12
-0
origin-kubeconfig.yaml
examples/openshift-origin/origin-kubeconfig.yaml
+0
-18
resource-generator.sh
examples/openshift-origin/resource-generator.sh
+0
-198
No files found.
examples/openshift-origin/README.md
View file @
52e94b1e
This diff is collapsed.
Click to expand it.
examples/openshift-origin/
delete-all
.sh
→
examples/openshift-origin/
cleanup
.sh
View file @
52e94b1e
...
@@ -14,21 +14,12 @@
...
@@ -14,21 +14,12 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
#
Deletes pod, deletes secre
t
#
Cleans up resources from the example, assumed to be run from Kubernetes repo roo
t
set
-o
errexit
export
OPENSHIFT_EXAMPLE
=
$(
pwd
)
/examples/openshift-origin
set
-o
nounset
export
OPENSHIFT_CONFIG
=
${
OPENSHIFT_EXAMPLE
}
/config
set
-o
pipefail
rm
-fr
${
OPENSHIFT_CONFIG
}
cluster/kubectl.sh delete secrets openshift-config
ORIGIN
=
$(
dirname
"
${
BASH_SOURCE
}
"
)
cluster/kubectl.sh stop rc openshift
KUBE_ROOT
=
$(
dirname
"
${
BASH_SOURCE
}
"
)
/../..
cluster/kubectl.sh delete rc openshift
cluster/kubectl.sh delete services openshift
## Delete the services
${
KUBE_ROOT
}
/cluster/kubectl.sh delete services origin-api
${
KUBE_ROOT
}
/cluster/kubectl.sh delete services origin-ui
## Delete the pod
${
KUBE_ROOT
}
/cluster/kubectl.sh delete pods openshift
## Delete the secret
${
KUBE_ROOT
}
/cluster/kubectl.sh delete secrets kubernetes-secret
examples/openshift-origin/create-all.sh
deleted
100755 → 0
View file @
b60a90c3
#!/bin/bash
# Copyright 2014 The Kubernetes Authors All rights reserved.
#
# 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.
# Generates secret, creates secret on kube, creates pod on kube
set
-o
errexit
set
-o
nounset
set
-o
pipefail
ORIGIN
=
$(
dirname
"
${
BASH_SOURCE
}
"
)
KUBE_ROOT
=
$(
dirname
"
${
BASH_SOURCE
}
"
)
/../..
## Generate resources
${
ORIGIN
}
/resource-generator.sh
## Create the secret
${
KUBE_ROOT
}
/cluster/kubectl.sh create
-f
${
ORIGIN
}
/secret.json
## Create the pod
${
KUBE_ROOT
}
/cluster/kubectl.sh create
-f
${
ORIGIN
}
/pod.json
## Create the services
${
KUBE_ROOT
}
/cluster/kubectl.sh create
-f
${
ORIGIN
}
/api-service.json
${
KUBE_ROOT
}
/cluster/kubectl.sh create
-f
${
ORIGIN
}
/ui-service.json
\ No newline at end of file
examples/openshift-origin/create.sh
0 → 100755
View file @
52e94b1e
#!/bin/bash
# Copyright 2014 The Kubernetes Authors All rights reserved.
#
# 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.
# Creates resources from the example, assumed to be run from Kubernetes repo root
export
OPENSHIFT_EXAMPLE
=
$(
pwd
)
/examples/openshift-origin
export
OPENSHIFT_CONFIG
=
${
OPENSHIFT_EXAMPLE
}
/config
mkdir
${
OPENSHIFT_CONFIG
}
cluster/kubectl.sh config view
--output
=
yaml
--flatten
=
true
--minify
=
true
>
${
OPENSHIFT_CONFIG
}
/kubeconfig
cluster/kubectl.sh create
-f
$OPENSHIFT_EXAMPLE
/openshift-service.yaml
sleep
30
export
PUBLIC_IP
=
$(
cluster/kubectl.sh get services openshift
--template
=
"{{ index .spec.publicIPs 0 }}"
)
echo
$PUBLIC_IP
export
PORTAL_IP
=
$(
cluster/kubectl.sh get services openshift
--template
=
"{{ .spec.portalIP }}"
)
echo
$PORTAL_IP
docker run
--privileged
-v
${
OPENSHIFT_CONFIG
}
:/config openshift/origin start master
--write-config
=
/config
--kubeconfig
=
/config/kubeconfig
--master
=
https://localhost:8443
--public-master
=
https://
${
PUBLIC_IP
}
:8443
sudo
-E
chown
${
USER
}
-R
${
OPENSHIFT_CONFIG
}
docker run
-i
-t
--privileged
-e
=
"OPENSHIFTCONFIG=/config/admin.kubeconfig"
-v
${
OPENSHIFT_CONFIG
}
:/config openshift/origin ex bundle-secret openshift-config
-f
/config &>
${
OPENSHIFT_EXAMPLE
}
/secret.json
cluster/kubectl.sh create
-f
${
OPENSHIFT_EXAMPLE
}
/secret.json
cluster/kubectl.sh create
-f
${
OPENSHIFT_EXAMPLE
}
/openshift-controller.yaml
cluster/kubectl.sh get pods |
grep
openshift
\ No newline at end of file
examples/openshift-origin/openshift-controller.yaml
0 → 100644
View file @
52e94b1e
apiVersion
:
v1beta3
kind
:
ReplicationController
metadata
:
labels
:
name
:
openshift
name
:
openshift
spec
:
replicas
:
1
selector
:
name
:
openshift
template
:
metadata
:
labels
:
name
:
openshift
spec
:
containers
:
-
args
:
-
start
-
master
-
--config=/config/master-config.yaml
image
:
"
openshift/origin"
name
:
origin
ports
:
-
containerPort
:
8443
name
:
openshift
volumeMounts
:
-
mountPath
:
/config
name
:
config
readOnly
:
true
volumes
:
-
name
:
config
secret
:
secretName
:
openshift-config
\ No newline at end of file
examples/openshift-origin/openshift-service.yaml
0 → 100644
View file @
52e94b1e
apiVersion
:
v1beta3
kind
:
Service
metadata
:
name
:
openshift
spec
:
ports
:
-
port
:
8443
name
:
openshift
targetPort
:
8443
selector
:
name
:
openshift
createExternalLoadBalancer
:
true
examples/openshift-origin/origin-kubeconfig.yaml
deleted
100644 → 0
View file @
b60a90c3
apiVersion
:
v1
clusters
:
-
cluster
:
certificate-authority
:
/etc/secret-volume/kube-ca
server
:
https://146.148.35.28
name
:
kubernetes
contexts
:
-
context
:
cluster
:
kubernetes
user
:
kubernetes-admin
name
:
kubernetes
current-context
:
kubernetes
kind
:
Config
preferences
:
{}
users
:
-
name
:
kubernetes-admin
user
:
auth-path
:
/etc/secret-volume/kube-auth-path
examples/openshift-origin/resource-generator.sh
deleted
100755 → 0
View file @
b60a90c3
#!/bin/bash
# Copyright 2014 The Kubernetes Authors All rights reserved.
#
# 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.
# Generates pod and secret to deploy origin against configured Kubernetes provider
set
-o
errexit
set
-o
nounset
set
-o
pipefail
ORIGIN
=
$(
dirname
"
${
BASH_SOURCE
}
"
)
KUBE_ROOT
=
$(
dirname
"
${
BASH_SOURCE
}
"
)
/../..
source
"
${
KUBE_ROOT
}
/cluster/kubectl.sh"
>
/dev/null 2>&1
# Check all prerequisites are on the path
HAVE_JQ
=
$(
which jq
)
if
[[
-z
${
HAVE_JQ
}
]]
;
then
echo
"Please install jq"
exit
1
fi
HAVE_BASE64
=
$(
which
base64
)
if
[[
-z
${
HAVE_BASE64
}
]]
;
then
echo
"Please install base64"
exit
1
fi
# Capture information about your kubernetes cluster
TEMPLATE
=
"--template=
\"
{{ index .
\"
current-context
\"
}}
\"
"
CURRENT_CONTEXT
=
$(
"
${
kubectl
}
"
"
${
config
[@]
:+
${
config
[@]
}}
"
config view
-o
template
"
${
TEMPLATE
}
"
)
TEMPLATE
=
"--template=
\"
{{range .contexts}}{{ if eq .name
${
CURRENT_CONTEXT
}
}}{{ .context.cluster }}{{end}}{{end}}
\"
"
CURRENT_CLUSTER
=
$(
"
${
kubectl
}
"
"
${
config
[@]
:+
${
config
[@]
}}
"
config view
-o
template
"
${
TEMPLATE
}
"
)
TEMPLATE
=
"--template=
\"
{{range .contexts}}{{ if eq .name
${
CURRENT_CONTEXT
}
}}{{ .context.user }}{{end}}{{end}}
\"
"
CURRENT_USER
=
$(
"
${
kubectl
}
"
"
${
config
[@]
:+
${
config
[@]
}}
"
config view
-o
template
"
${
TEMPLATE
}
"
)
TEMPLATE
=
"--template=
\"
{{range .clusters}}{{ if eq .name
${
CURRENT_CLUSTER
}
}}{{ index .
\"
cluster
\"
\"
certificate-authority
\"
}}{{end}}{{end}}
\"
"
CERTIFICATE_AUTHORITY
=
$(
"
${
kubectl
}
"
"
${
config
[@]
:+
${
config
[@]
}}
"
config view
-o
template
"
${
TEMPLATE
}
"
)
TEMPLATE
=
"--template=
\"
{{range .clusters}}{{ if eq .name
${
CURRENT_CLUSTER
}
}}{{ .cluster.server }}{{end}}{{end}}
\"
"
KUBE_MASTER
=
$(
"
${
kubectl
}
"
"
${
config
[@]
:+
${
config
[@]
}}
"
config view
-o
template
"
${
TEMPLATE
}
"
)
TEMPLATE
=
"--template=
\"
{{range .users}}{{ if eq .name
${
CURRENT_USER
}
}}{{ index .
\"
user
\"
\"
auth-path
\"
}}{{end}}{{end}}
\"
"
AUTH_PATH
=
$(
"
${
kubectl
}
"
"
${
config
[@]
:+
${
config
[@]
}}
"
config view
-o
template
"
${
TEMPLATE
}
"
)
# Build an auth_path file to embed as a secret
AUTH_PATH_DATA
=
$(
cat
${
AUTH_PATH
}
)
KUBE_USER
=
$(
echo
${
AUTH_PATH_DATA
}
| jq
'.User'
)
KUBE_PASSWORD
=
$(
echo
${
AUTH_PATH_DATA
}
| jq
'.Password'
)
KUBE_CERT_FILE
=
$(
echo
${
AUTH_PATH_DATA
}
| jq
'.CertFile'
)
KUBE_KEY_FILE
=
$(
echo
${
AUTH_PATH_DATA
}
| jq
'.KeyFile'
)
cat
<<
EOF
>"
${
ORIGIN
}
/origin-auth-path"
{
"User":
${
KUBE_USER
}
,
"Password":
${
KUBE_PASSWORD
}
,
"CAFile": "/etc/secret-volume/kube-ca",
"CertFile": "/etc/secret-volume/kube-cert",
"KeyFile": "/etc/secret-volume/kube-key"
}
EOF
# Collect all the secrets and encode as base64
ORIGIN_KUBECONFIG_DATA
=
$(
cat
${
ORIGIN
}
/origin-kubeconfig.yaml |
base64
--wrap
=
0
)
ORIGIN_CERTIFICATE_AUTHORITY_DATA
=
$(
cat
${
CERTIFICATE_AUTHORITY
}
|
base64
--wrap
=
0
)
ORIGIN_AUTH_PATH_DATA
=
$(
cat
${
ORIGIN
}
/origin-auth-path |
base64
--wrap
=
0
)
ORIGIN_CERT_FILE
=
$(
cat
${
KUBE_CERT_FILE
//\
"/} | base64 --wrap=0)
ORIGIN_KEY_FILE=
$(
cat
${
KUBE_KEY_FILE
//\
"/} | base64 --wrap=0)
cat <<EOF >"
${
ORIGIN
}
/secret.json
"
{
"
apiVersion
": "
v1beta2
",
"
kind
": "
Secret
",
"
id
": "
kubernetes
-secret
",
"
data
": {
"
kubeconfig
": "
${
ORIGIN_KUBECONFIG_DATA
}
",
"
kube
-ca
": "
${
ORIGIN_CERTIFICATE_AUTHORITY_DATA
}
",
"
kube
-auth-path
": "
${
ORIGIN_AUTH_PATH_DATA
}
",
"
kube
-cert
": "
${
ORIGIN_CERT_FILE
}
",
"
kube
-key
": "
${
ORIGIN_KEY_FILE
}
"
}
}
EOF
echo "
Generated
Kubernetes Secret file
:
${
ORIGIN
}
/secret.json
"
# Generate an OpenShift Origin pod
# TODO: In future, move this to a replication controller when we are not running etcd in container
cat <<EOF >"
${
ORIGIN
}
/pod.json
"
{
"
apiVersion
": "
v1beta1
",
"
id
": "
openshift
",
"
kind
": "
Pod
",
"
labels
": {"
name
": "
origin
"},
"
desiredState
": {
"
manifest
": {
"
containers
": [
{
"
command
": [
"
start
",
"
master
",
"
--kubernetes=
${
KUBE_MASTER
}
",
"
--kubeconfig=/etc/secret-volume/kubeconfig
",
"
--public-kubernetes=https
://10.245.1.3:8443
",
"
--public-master=https
://10.245.1.3:8443
",
],
"
image
": "
openshift
/origin
:latest
",
"
imagePullPolicy
": "
PullIfNotPresent
",
"
name
": "
origin
",
"
ports
": [
{
"
name
": "
https
-api
",
"
containerPort
": 8443,
"
hostPort
": 8443,
},
{
"
name
": "
https
-ui
",
"
containerPort
": 8444,
"
hostPort
": 8444,
}
],
"
volumeMounts
": [
{
"
mountPath
": "
/etc/secret-volume
",
"
name
": "
secret
-volume
",
"
readOnly
": true
}
]
}
],
"
restartPolicy
": {
"
never
": {}
},
"
version
": "
v1beta2
",
"
volumes
": [
{
"
name
": "
secret
-volume
",
"
source
": {
"
secret
": {
"
target
": {
"
kind
": "
Secret
",
"
name
": "
kubernetes
-secret
",
"
namespace
": "
default
"
}
}
}
}
]
}
}
}
EOF
echo "
Generated
Kubernetes Pod file
:
${
ORIGIN
}
/pod.json
"
cat <<EOF >"
${
ORIGIN
}
/api-service.json
"
{
"
apiVersion
": "
v1beta1
",
"
kind
": "
Service
",
"
id
": "
origin
-api
",
"
port
": 8443,
"
containerPort
": 8443,
"
selector
": { "
name
": "
origin
" },
}
EOF
echo "
Generated
Kubernetes Service file
:
${
ORIGIN
}
/api-service.json
"
cat <<EOF >"
${
ORIGIN
}
/ui-service.json
"
{
"
apiVersion
": "
v1beta1
",
"
kind
": "
Service
",
"
id
": "
origin
-ui
",
"
port
": 8444,
"
containerPort
": 8444,
"
selector
": { "
name
": "
origin
" },
}
EOF
echo "
Generated
Kubernetes Service file
:
${
ORIGIN
}
/ui-service.json
"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment