Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Snapshot for standalone planner UI #2426

Closed
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
81c2076
added new stages in release.groovy for building and pushing standalon…
pranavgore09 Jan 31, 2018
c2ecced
Merge remote-tracking branch 'upstream/master' into standalone-planne…
pranavgore09 Jan 31, 2018
4fe072e
Merge remote-tracking branch 'upstream/master' into standalone-planne…
pranavgore09 Feb 1, 2018
81b5cd4
ignore runtime/node_modules while building image for standalone plann…
pranavgore09 Feb 1, 2018
c4c83cc
Merge remote-tracking branch 'upstream/master' into standalone-planne…
pranavgore09 Feb 1, 2018
c1fda0c
Merge remote-tracking branch 'upstream/master' into standalone-planne…
pranavgore09 Feb 2, 2018
8fc8d3f
increase timeout to let the build get more time to run.
pranavgore09 Feb 2, 2018
f4f818c
added deployments in openshift
pranavgore09 Feb 2, 2018
7aeebd0
update YAML path to download
pranavgore09 Feb 2, 2018
80575e1
update commit message
pranavgore09 Feb 2, 2018
8d3e25a
no need to add TAG in original image name
pranavgore09 Feb 3, 2018
388d655
use default and add IMAGE_TAG later
pranavgore09 Feb 3, 2018
a282f3b
update environment
pranavgore09 Feb 3, 2018
e1c90ef
remove maintainer
pranavgore09 Feb 4, 2018
86a1d7c
bake ENV into the image
pranavgore09 Feb 4, 2018
3132ef2
remove config file and use original image name
pranavgore09 Feb 5, 2018
f850964
ignore fabric8-ui added in jenkins while docker build.
pranavgore09 Feb 5, 2018
0be09ea
build essential stages only
pranavgore09 Feb 5, 2018
c13e215
perform npm inside container('ui')
pranavgore09 Feb 5, 2018
cc76762
separate ENV vars from planner and K8S
pranavgore09 Feb 5, 2018
fc910c6
remove config
pranavgore09 Feb 5, 2018
932fb6f
resume older stages
pranavgore09 Feb 5, 2018
e2348f6
Merge remote-tracking branch 'upstream/master' into standalone-planne…
pranavgore09 Feb 5, 2018
030cc2e
Merge remote-tracking branch 'upstream/master' into standalone-planne…
pranavgore09 Feb 7, 2018
cbfdc5a
Merge remote-tracking branch 'upstream/master' into standalone-planne…
pranavgore09 Feb 9, 2018
c5da551
Merge branch 'master' into standalone-plannerUI-snapshot
nimishamukherjee Feb 12, 2018
9c38eb7
Merge remote-tracking branch 'upstream/master' into standalone-planne…
pranavgore09 Feb 12, 2018
1131f68
Merge branch 'standalone-plannerUI-snapshot' of github.com:pranavgore…
pranavgore09 Feb 12, 2018
f7a21f2
Merge branch 'master' into standalone-plannerUI-snapshot
pranavgore09 Feb 12, 2018
0ae5da9
Merge remote-tracking branch 'upstream/master' into standalone-planne…
pranavgore09 Feb 13, 2018
caa661c
Merge remote-tracking branch 'upstream/master' into standalone-planne…
pranavgore09 Feb 15, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules
*~
*.swp
runtime/node_modules
fabric8-ui
11 changes: 11 additions & 0 deletions Dockerfile.deploy.runtime
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM fabric8/fabric8-openshift-nginx:vd83b3a1

USER root

RUN rm -rf /usr/share/nginx/html/
COPY ./runtime/dist /usr/share/nginx/html
RUN chmod -R 777 /var/lib/nginx/
RUN chmod -R 777 /usr/share/nginx/html/


USER ${FABRIC8_USER_NAME}
45 changes: 38 additions & 7 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
@Library('github.com/fabric8io/fabric8-pipeline-library@master')
@Library('github.com/pranavgore09/fabric8-pipeline-library@standalone-planner')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're using some custom code, send PR to main repo and switch the DIFF back.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def utils = new io.fabric8.Utils()
def flow = new io.fabric8.Fabric8Commands()
def project = 'fabric8-ui/fabric8-planner'
def ciDeploy = false
def tempVersion
def imageName
def standaloneImageName
node{
properties([
disableConcurrentBuilds()
Expand All @@ -25,15 +26,17 @@ fabric8UITemplate{
container('ui'){
tempVersion = pipeline.ciBuildDownstreamProject(project)
}

imageName = "fabric8/fabric8-ui:${tempVersion}"
container('docker'){
pipeline.buildImage(imageName)
}

standaloneImageName = "fabric8/fabric8-planner:${tempVersion}"
container('docker'){
pipeline.getStandaloneImage(standaloneImageName)
}
ciDeploy = true


} else if (utils.isCD()){
sh "git checkout master"
sh "git pull"
Expand Down Expand Up @@ -69,10 +72,10 @@ fabric8UITemplate{

// deploy a snapshot fabric8-ui pod and notify pull request of details
if (ciDeploy){
def prj = 'fabric8-ui-'+ env.BRANCH_NAME
prj = prj.toLowerCase()
def route
timeout(time: 10, unit: 'MINUTES') {
timeout(time: 50, unit: 'MINUTES') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

50 minutes sounds pretty long.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I understand but sometimes even 1h is less,
we face errors like below where Jenkins-slave is unavailable for the random amount of time.

Still waiting to schedule task
Jenkins doesn’t have label dockerfabric8_planner_27

In best case 10m is sufficient but current builds may take more time and timeout with a small timeout value.
Cancelling nested steps due to timeout. Could not connect to jenkins-slave-prxp7-mp5d9 to send interrupt signal to process

def prj = 'fabric8-ui-'+ env.BRANCH_NAME
prj = prj.toLowerCase()
def route
deployOpenShiftNode(openshiftConfigSecretName: 'fabric8-intcluster-config'){
stage("deploy ${prj}"){
route = deployOpenShiftSnapshot{
Expand All @@ -99,5 +102,33 @@ if (ciDeploy){
}
}
}
prj = 'f8-plan-std'+ env.BRANCH_NAME
prj = prj.toLowerCase()
deployOpenShiftNode(openshiftConfigSecretName: 'fabric8-intcluster-config'){
stage("deploy ${prj}"){
route = deployPlannerSnapshot{
openShiftProject = prj
openShiftTemplate = 'https://raw.githubusercontent.com/pranavgore09/fabric8-planner/standalone-plannerUI-snapshot/openshift/fabric8-planner.app.yml'
originalImageName = 'fabric8/fabric8-planner'
newImageName = standaloneImageName
githubRepo = 'fabric8-planner'
githubProject = project
}
}
stage("notify for ${prj}"){
def changeAuthor = env.CHANGE_AUTHOR
if (!changeAuthor){
error "no commit author found so cannot comment on PR"
}
def pr = env.CHANGE_ID
if (!pr){
error "no pull request number found so cannot comment on PR"
}
def message = "@${changeAuthor} ${imageName} standalone planner UI is deployed and available for testing at http://${route}"
container('clients'){
flow.addCommentToPullRequest(message, pr, project)
}
}
}
}
}
34 changes: 34 additions & 0 deletions deploy/release.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,40 @@ def buildImage(imageName){
}
}

def getStandaloneImage(imageName){
stage('build standalone npm') {
container('ui'){
sh '''
npm install
npm run build
npm pack dist/
'''
}
dir('runtime'){
container('ui'){
sh 'npm cache clean --force'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required in a fresh environment, unless you have found a reason why it's needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@debloper I don't think the environment is fresh when we rebuild the PR. At times PR build fails due to npm integrity errors. This command makes sure the environment is fresh before we start building the PR.

sh 'npm install'
sh '''
export API_URL=https://api.prod-preview.openshift.io/api/
export FABRIC8_REALM=fabric8-test
export FABRIC8_WIT_API_URL=https://api.prod-preview.openshift.io/api/
export FABRIC8_SSO_API_URL=https://sso.prod-preview.openshift.io/
export FABRIC8_AUTH_API_URL=https://auth.prod-preview.openshift.io/api/
npm run build
'''
}
}
}

stage('build standalone snapshot image'){
sh "docker build -t ${imageName} -f ./Dockerfile.deploy.runtime ."
}

stage('push standalone snapshot image'){
sh "docker push ${imageName}"
}
}

def cd (b){
stage('fix git repo'){
sh './scripts/fix-git-repo.sh'
Expand Down
161 changes: 161 additions & 0 deletions openshift/fabric8-planner.app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
apiVersion: v1
kind: Template
metadata:
name: f8planner
creationTimestamp: null
objects:
- apiVersion: v1
kind: DeploymentConfig
metadata:
creationTimestamp: null
generation: 1
labels:
service: f8planner
app: fabric8-planner
provider: fabric8
name: f8planner
spec:
replicas: 3
selector:
service: f8planner
strategy:
resources: {}
rollingParams:
intervalSeconds: 1
maxSurge: 25%
maxUnavailable: 25%
timeoutSeconds: 600
updatePeriodSeconds: 1
type: Rolling
template:
metadata:
creationTimestamp: null
labels:
service: f8planner
app: fabric8-planner
provider: fabric8
spec:
containers:
- image: fabric8/fabric8-planner:standalone
imagePullPolicy: Always
name: f8planner
ports:
- containerPort: 80
protocol: TCP
env:
- name: WS_K8S_API_SERVER
value: ${WS_K8S_API_SERVER}
- name: K8S_API_SERVER_PROTOCOL
value: ${K8S_API_SERVER_PROTOCOL}
- name: K8S_API_SERVER_BASE_PATH
value: ${K8S_API_SERVER_BASE_PATH}
- name: OAUTH_ISSUER
value: ${OAUTH_ISSUER}
- name: OAUTH_CLIENT_ID
value: ${OAUTH_CLIENT_ID}
- name: OAUTH_SCOPE
value: ${OAUTH_SCOPE}
- name: OAUTH_AUTHORIZE_URI
value: ${OAUTH_AUTHORIZE_URI}
- name: AUTH_LOGOUT_URI
value: ${AUTH_LOGOUT_URI}
- name: FABRIC8_PIPELINES_NAMESPACE
value: ${FABRIC8_PIPELINES_NAMESPACE}
- name: PROXIED_K8S_API_SERVER
value: ${PROXIED_K8S_API_SERVER}
- name: PROXY_PASS_URL
value: ${PROXY_PASS_URL}
- name: FABRIC8_RECOMMENDER_API_URL
value: ${FABRIC8_RECOMMENDER_API_URL}
- name: FABRIC8_FORGE_API_URL
value: ${FABRIC8_FORGE_API_URL}
- name: OPENSHIFT_CONSOLE_URL
value: ${OPENSHIFT_CONSOLE_URL}
resources: {}
terminationMessagePath: /dev/termination-log
readinessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 20
timeoutSeconds: 10
livenessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 120
timeoutSeconds: 10
dnsPolicy: ClusterFirst
restartPolicy: Always
securityContext: {}
terminationGracePeriodSeconds: 30
test: false
triggers:
- type: ConfigChange
status: {}
- apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
service: f8planner
app: fabric8-planner
provider: fabric8
name: f8planner
spec:
ports:
- name: "8080"
port: 8080
protocol: TCP
targetPort: 8080
selector:
service: f8planner
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
- apiVersion: v1
kind: Route
metadata:
creationTimestamp: null
labels:
service: f8planner
app: fabric8-planner
provider: fabric8
name: fabric8-planner
spec:
host: ''
port:
targetPort: "8080"
to:
kind: Service
name: f8planner
weight: 100
wildcardPolicy: None
status: {}
parameters:
- name: WS_K8S_API_SERVER
value: api.free-int.openshift.com:443
- name: K8S_API_SERVER_PROTOCOL
value: https
- name: K8S_API_SERVER_BASE_PATH
value: /_p/oso
- name: OAUTH_ISSUER
value: https://api.free-int.openshift.com:443
- name: OAUTH_CLIENT_ID
value: fabric8
- name: OAUTH_SCOPE
value: user:full
- name: OAUTH_AUTHORIZE_URI
value: https://api.free-int.openshift.com:443/oauth/authorize
- name: AUTH_LOGOUT_URI
value: https://api.free-int.openshift.com:443/connect/endsession?id_token={{id_token}}
- name: FABRIC8_PIPELINES_NAMESPACE
- name: PROXY_PASS_URL
value: https://api.free-int.openshift.com:443
- name: OPENSHIFT_CONSOLE_URL
value: https://console.free-int.openshift.com/console/
- name: PROXIED_K8S_API_SERVER
value: api.free-int.openshift.com:443
- name: FABRIC8_RECOMMENDER_API_URL
value: https://api-bayesian.dev.rdu2c.fabric8.io/api/v1/
- name: FABRIC8_FORGE_API_URL
value: https://forge.api.prod-preview.openshift.io