Skip to content

Instantly share code, notes, and snippets.

View iocanel's full-sized avatar

Ioannis Canellos iocanel

View GitHub Profile
@iocanel
iocanel / workflow.groovy
Last active September 15, 2016 03:06
Example of using kubernetes workflow to build, tag, push images to the docker registry.
node {
git 'https://github.com/rawlingsj/node-example.git'
if (!fileExists ('Dockerfile')) {
writeFile file: 'Dockerfile', text: 'FROM node:5.3-onbuild'
}
kubernetes.image().withName("example").build().fromPath(".")
kubernetes.image().withName("example").tag().inRepository("172.30.101.121:5000/default/example").withTag("1.0")
kubernetes.image().withName("172.30.101.121:5000/default/example").push().withTag("1.0").toRegistry()
}
@iocanel
iocanel / workflow.groovy
Last active January 22, 2016 17:23
jenkins kubernetes workflow testing
node('kubernetes') {
kubernetes.pod('mypod').withImage('maven').inside {
git 'https://github.com/fabric8io-images/s2i.git'
kubernetes.image().withName("my-java-s2i").build().fromPath("java")
kubernetes.image().withName("my-java-s2i").tag().inRepository("my-java-s2i").withTag("1.0")
kubernetes.image().withName("my-java-s2i").push().withTag("1.0").toRegistry()
}
}
@iocanel
iocanel / where-do-i-run.groovy
Created January 21, 2016 09:28
Understanding what runs where in Jenkins + Kubernetes
node {
def hostname = readFile '/etc/hostname'
echo "Local node hostname: $hostname"
}
node('kubernetes') {
def hostname = readFile '/etc/hostname'
echo "Kubernetes slave hostname: $hostname"
}
@iocanel
iocanel / kubews.sh
Last active December 16, 2015 13:27
Helper script for using curl with kubernetes ws
#!/bin/bash
KUBE_TOKEN=`cat ~/.kube/config | grep token | awk -F " " '{print $2}'`
curl -sSk -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" \
-H "Sec-WebSocket-Key: MKuU3hrynEXL1F00D3ZyOQ==" \
-H "Sec-WebSocket-Version: 13" \
-H "Authorization: Bearer $KUBE_TOKEN" $1
@iocanel
iocanel / jenkins.sh
Created December 15, 2015 12:58
Jenkins launcher command
nohup sh -c echo $$$$ > '/home/jenkins/workspace/workspace/test-workflow17/.5fc8d3e8/pid'
jsc=durable-d0ccb5e108e2e57946d9472370a62c5f
JENKINS_SERVER_COOKIE=$$jsc '/home/jenkins/workspace/workspace/test-workflow17/.5fc8d3e8/script.sh' > '/home/jenkins/workspace/workspace/test-workflow17/.5fc8d3e8/jenkins-log.txt' 2>&1
echo $$? > '/home/jenkins/workspace/workspace/test-workflow17/.5fc8d3e8/jenkins-result.txt'
@iocanel
iocanel / gist:657a778e725eca1e37ea
Created December 15, 2015 09:36
Allow exec into privileged containers
oadm policy add-scc-to-user privileged admin
oadm policy add-scc-to-user privileged system:serviceaccount:fabric8
@iocanel
iocanel / gist:aad9e70eb6ae185463bb
Created December 11, 2015 14:07
Weird Kubernetes exec response
bash #oc exec mypod-17817053-320d-4659-8b58-dd45f3c09544 ls
Error from server: pods "mypod-17817053-320d-4659-8b58-dd45f3c09544" is forbidden: unable to validate against any security context constraint: [provider restricted: .spec.containers[0].securityContext.privileged: invalid value 'true', Details: Privileged containers are not allowed provider restricted: .spec.containers[0].securityContext.VolumeMounts: invalid value 'workspace', Details: Host Volumes are not allowed to be used]
@iocanel
iocanel / gist:b3a0a93611a44fa8badf
Created December 1, 2015 11:23
Weird permission issue with hostPath mounts
drwxr-xr-x. 6 root root 101 Dec 1 11:15 .
drwxr-xr-x. 3 root root 4096 Dec 1 11:15 ..
drwxr-xr-x. 2 root root 22 Dec 1 11:15 .f0a5421a
drwxr-xr-x. 7 root root 4096 Dec 1 11:15 .git
??????????? ? ? ? ? ? .gitignore
drwxr-xr-x. 2 root root 24 Dec 1 11:15 .sti
??????????? ? ? ? ? ? README.md
??????????? ? ? ? ? ? pom.xml
@iocanel
iocanel / gist:2de1cf8e7a981bce7695
Created October 6, 2015 09:42
To Docker Workflow or Not?
# with docker workflow
node('docker') {
docker.image('maven').inside {
git 'https://github.com/fabric8io/example-camel-cdi'
sh 'mvn clean install'
}
}
#without docker workflow
node('maven') {
@iocanel
iocanel / arquillian.xml
Created September 18, 2015 14:34
Dependencies to Kuberntes JSON inside an arquillian.xml descriptor
<?xml version="1.0"?>
<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://jboss.org/schema/arquillian"
xsi:schemaLocation="http://jboss.org/schema/arquillian
http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<extension qualifier="kubernetes">
<property name="dependencies">mvn:groupId/artifactId/version/json</property>
</extension>