Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hello-world-minishift
Manage
Activity
Members
Plan
JetBrains YouTrack
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ronald DC
hello-world-minishift
Commits
34f4163d
Commit
34f4163d
authored
7 years ago
by
Ronald DC
💬
Browse files
Options
Downloads
Patches
Plain Diff
Added sample project configs and script
parent
fa6bf1ae
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
create-project.sh
+36
-0
36 additions, 0 deletions
create-project.sh
index.js
+6
-6
6 additions, 6 deletions
index.js
minishift-demo.yaml
+180
-0
180 additions, 0 deletions
minishift-demo.yaml
with
222 additions
and
6 deletions
create-project.sh
0 → 100755
+
36
−
0
View file @
34f4163d
#!/bin/bash
DIR
=
"
$(
cd
"
$(
dirname
"
$0
"
)
"
&&
pwd
)
"
PROJECT
=
${
PROJECT
:
=minishift-demo
}
APP_NAME
=
${
APP_NAME
:
=hello-server
}
echo
"Creating demo application..."
echo
"=========================="
echo
"(1/4) Applying extra permissions..."
# This adds anyuid and hostaccess security context constraints to default service account
# This is acceptable for a dev environment only
oc login
-u
system:admin
oc adm policy add-scc-to-user anyuid system:serviceaccount:
$PROJECT
:default
oc adm policy add-scc-to-user hostaccess system:serviceaccount:
$PROJECT
:default
echo
"developer"
| oc login
-u
developer
echo
"=========================="
echo
"(2/4) Creating new project..."
oc new-project
$PROJECT
--display-name
=
"Demo Project"
--description
=
"A demo project designed to help you start developing with Minishift"
>
/dev/null
echo
"=========================="
echo
"(3/4) Deploying hello-server..."
oc process
-f
"
$DIR
"
/minishift-demo.yaml
\
-p
NAMESPACE
=
$PROJECT
\
-p
NAME
=
$APP_NAME
\
-p
PROBE
=
/healthz
\
-p
SERVER_PORT
=
8080
\
-p
LOG_LEVEL
=
debug
\
-p
APP_VOLUME
=
"
${
DIR
}
"
| oc create
-f
-
echo
"(4/4) Building hello-server Image"
oc start-build
$APP_NAME
--from-dir
$DIR
--follow
This diff is collapsed.
Click to expand it.
index.js
+
6
−
6
View file @
34f4163d
...
...
@@ -13,7 +13,7 @@ const pino = require('pino')({
const
server
=
restify
.
createServer
({
name
:
'
hello
'
})
server
.
get
(
'
/
'
,
function
(
req
,
res
,
next
)
{
res
.
json
({
msg
:
'
Hello
World
'
})
res
.
json
({
msg
:
'
Hello
Universe, kjfheskfhsekfhe
'
})
return
next
()
})
...
...
@@ -23,21 +23,21 @@ server.get('/healthz', function (req, res, next) {
return
next
()
})
server
.
get
(
'
/version
'
,
function
(
req
,
res
,
next
){
server
.
get
(
'
/version
'
,
function
(
req
,
res
,
next
)
{
res
.
json
({
version
:
'
1.1
'
})
return
next
()
})
server
.
get
(
'
/time
'
,
function
(
req
,
res
,
next
)
{
server
.
get
(
'
/time
'
,
function
(
req
,
res
,
next
)
{
var
t
=
new
Date
()
db
.
put
(
'
time
'
,
t
,
function
(
err
)
{
if
(
err
)
{
res
.
status
(
500
)
res
.
json
({
msg
:
'
An error occurred
'
})
res
.
json
({
msg
:
'
An error occurred
'
})
return
next
(
err
)
}
res
.
json
({
msg
:
t
})
res
.
json
({
msg
:
t
})
return
next
()
})
})
...
...
This diff is collapsed.
Click to expand it.
minishift-demo.yaml
0 → 100644
+
180
−
0
View file @
34f4163d
---
apiVersion
:
v1
kind
:
Template
labels
:
template
:
minishift-demo
parameters
:
-
description
:
The name assigned to all of the frontend objects defined in this template.
displayName
:
Name
name
:
NAME
required
:
true
value
:
minishift-demo
-
description
:
The OpenShift Namespace where the ImageStream resides.
displayName
:
Namespace
name
:
NAMESPACE
required
:
true
value
:
minishift-demo
-
description
:
Maximum amount of memory the container can use.
displayName
:
Memory Limit
name
:
MEMORY_LIMIT
required
:
true
value
:
128Mi
-
description
:
Set this to the relative path to your project if it is not in the root of your repository.
displayName
:
Context Directory
name
:
CONTEXT_DIR
-
description
:
The exposed hostname that will route to the Node.js service, if left blank a value will be defaulted.
displayName
:
Application Hostname
name
:
APPLICATION_DOMAIN
value
:
'
'
-
description
:
The path of the readiness probe and liveness probe
displayName
:
Path Probe
name
:
PROBE
value
:
'
'
-
description
:
The local path where the application is stored
displayName
:
App volume
name
:
APP_VOLUME
required
:
true
value
:
'
'
-
description
:
The port the server will run on inside the container
displayName
:
Server Port
name
:
SERVER_PORT
value
:
'
8080'
-
description
:
Log level applied to the process
displayName
:
Log Level
name
:
LOG_LEVEL
value
:
'
debug'
objects
:
-
apiVersion
:
v1
kind
:
BuildConfig
metadata
:
annotations
:
description
:
Defines how to build the application
name
:
"
${NAME}"
spec
:
runPolicy
:
Serial
output
:
to
:
kind
:
ImageStreamTag
name
:
"
${NAME}:latest"
source
:
type
:
Binary
strategy
:
type
:
Docker
triggers
:
-
type
:
ConfigChange
-
apiVersion
:
v1
kind
:
ImageStream
metadata
:
annotations
:
description
:
Keeps track of changes in the application image
name
:
"
${NAME}"
-
apiVersion
:
v1
kind
:
Service
metadata
:
annotations
:
description
:
Exposes and load balances the application pods
name
:
"
${NAME}"
spec
:
ports
:
-
name
:
http
port
:
8080
targetPort
:
8080
selector
:
name
:
"
${NAME}"
-
apiVersion
:
v1
kind
:
Route
metadata
:
name
:
"
${NAME}"
spec
:
host
:
"
${APPLICATION_DOMAIN}"
to
:
kind
:
Service
name
:
"
${NAME}"
-
apiVersion
:
v1
kind
:
DeploymentConfig
metadata
:
annotations
:
description
:
Defines how to deploy the application server
name
:
"
${NAME}"
spec
:
replicas
:
1
selector
:
name
:
"
${NAME}"
strategy
:
type
:
Recreate
template
:
metadata
:
labels
:
name
:
"
${NAME}"
name
:
"
${NAME}"
spec
:
containers
:
-
name
:
${NAME}
command
:
-
npm
-
run
-
start:dev
env
:
-
name
:
"
SERVER_PORT"
value
:
"
${SERVER_PORT}"
-
name
:
"
LOG_LEVEL"
value
:
"
${LOG_LEVEL}"
image
:
"
${NAMESPACE}/${NAME}:latest"
livenessProbe
:
httpGet
:
path
:
"
${PROBE}"
port
:
8080
initialDelaySeconds
:
30
timeoutSeconds
:
3
volumeMounts
:
-
mountPath
:
/usr/src/app/bin
name
:
app-volume
-
mountPath
:
/usr/src/app/bin/testdb
name
:
leveldb-volume
-
mountPath
:
/usr/src/app/bin/node_modules
name
:
empty-nodemodules
-
mountPath
:
/.config
name
:
nodemon-volume
ports
:
-
containerPort
:
8080
readinessProbe
:
httpGet
:
path
:
"
${PROBE}"
port
:
8080
initialDelaySeconds
:
3
timeoutSeconds
:
3
resources
:
limits
:
memory
:
"
${MEMORY_LIMIT}"
requests
:
memory
:
50Mi
volumes
:
-
name
:
app-volume
hostPath
:
path
:
"
${APP_VOLUME}"
-
name
:
nodemon-volume
-
name
:
empty-nodemodules
-
name
:
leveldb-volume
triggers
:
-
type
:
ConfigChange
-
type
:
ImageChange
imageChangeParams
:
automatic
:
true
containerNames
:
-
${NAME}
from
:
kind
:
ImageStreamTag
name
:
"
${NAME}:latest"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment