Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - Development #6

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -20,3 +20,5 @@ myapp-dev-ing.yaml
myapp-secret-dev.yaml
myapp-test-ing.yaml
myapp-secret-staging.yaml
synths/dist
synths/node_modules
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@ myapp-dev-ing.yaml
myapp-secret-dev.yaml
myapp-test-ing.yaml
myapp-secret-test.yaml

# synths/imports
synths/imports/*.js
synths/imports/*.d.ts
synths/dist
synths/node_modules
!synths/jest.config.js
synths/*.js
synths/*.d.ts
synths/__snapshots__/*.test.ts.snap
4 changes: 3 additions & 1 deletion .stignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Dockerfile
Jenkinsfile
Procfile
charts/
jenkins/
# jenkins/
log/
node_modules/
public/assets
Expand All @@ -20,3 +20,5 @@ myapp-dev-ing.yaml
myapp-secret-dev.yaml
myapp-test-ing.yaml
myapp-secret-staging.yaml
synths/dist
synths/node_modules
3 changes: 2 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ GEM

PLATFORMS
x86_64-darwin-19
x86_64-linux

DEPENDENCIES
rake (~> 13.0)
Expand All @@ -15,4 +16,4 @@ RUBY VERSION
ruby 3.0.0p0

BUNDLED WITH
2.2.3
2.2.7
17 changes: 16 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,27 @@ pipeline {
apiVersion: v1
kind: Pod
spec:
volumes:
- name: ssh-deploy-key
secret:
secretName: flux-synths-writer-ssh
nodeSelector:
jenkins.teamhephy.info/dockerbuilder: ruby
tolerations:
- key: jenkins.teamhephy.info/dockerbuilder
operator: Equal
value: ruby
effect: NoSchedule
containers:
- name: test
image: ${dockerRepoHost}/${dockerRepoUser}/${dockerRepoProj}:jenkins_${gitCommit}
imagePullPolicy: Never
securityContext:
runAsUser: 1000
volumeMounts:
- name: ssh-deploy-key
readOnly: true
mountPath: "/home/jenkins/.ssh"
command:
- cat
resources:
Expand All @@ -98,7 +113,7 @@ pipeline {
// to run with user 1000, NB. this is a hard requirement of Jenkins,
// (this is not a requirement of docker or rvm-docker-support)
container('test') {
sh (script: "cd /home/rvm/app && ./jenkins/rake-ci.sh")
sh (script: "cd /home/rvm/app && GIT_COMMIT=${gitCommit} ssh-agent ./jenkins/rake-ci.sh")
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions jenkins/docker-pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,10 @@ spec:
memory: 2Gi
cpu: 1
tty: true
nodeSelector:
jenkins.teamhephy.info/dockerbuilder: ruby
tolerations:
- key: jenkins.teamhephy.info/dockerbuilder
operator: Equal
value: ruby
effect: NoSchedule
40 changes: 36 additions & 4 deletions jenkins/rake-ci.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,39 @@
#!/bin/bash

source /etc/profile.d/rvm.sh
rvm ${RUBY}@testing
GIT_REPO=git@github.com:kingdonb/example-cdk8s-ruby.git
# GIT_REPO=https://github.com/kingdon-ci/example-cdk8s-ruby

bundle check
bundle exec rake ci
# run cdk8s to hydrate yamls in dist/
pushd synths
npm install

# run compile and test (fail the script and exit if test fails)
set -ex
npm run compile
npm run test
set +ex

# execute "synth" and make our synthetized yamls
cdk8s synth

# verbose
set -x

# add the SSH key mounted from secret, and clone git branch 'synths'
ssh-add ~/.ssh/id_ed25519_flux
git clone $GIT_REPO -b synths git-dist
cd git-dist

# prune (dist is only generating one file anyway)
mv -f ../dist/synths.k8s.yaml ./

# generate a new commit on synths branch and push
# FIXME: branches other than (whatever) should not result in a commit
git add synths.k8s.yaml
git config --global user.email "kingdon-ci@nerdland.info"
git config --global user.name "kingdon-ci Robot (Jenkins)"
git commit -m"built synth.k8s from $GIT_COMMIT" synths.k8s.yaml
git push origin synths

# all done
popd
3 changes: 3 additions & 0 deletions jenkins/runasroot-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ apt-get upgrade -y --no-install-recommends
# curl -sL https://deb.nodesource.com/setup_14.x | bash -
# curl -o- -L https://yarnpkg.com/install.sh | bash

npm install -g cdk8s-cli
# yarn global add cdk8s-cli

# Clean up
apt-get clean
rm -rf /var/lib/apt/lists/*
13 changes: 13 additions & 0 deletions okteto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: cdk-gitpusher
image: docker.io/kingdonb/cdk-gitpusher:bundler
command: [ "bash", "--login" ]
workdir: /home/rvm/app
forward:
- 3000:3000
- 1234:1234
persistentVolume:
enabled: true
securityContext:
runAsUser: 999
runAsGroup: 1000
fsGroup: 1000
4 changes: 4 additions & 0 deletions synths/cdk8s.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: typescript
app: node main.js
imports:
- k8s
23 changes: 23 additions & 0 deletions synths/help
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
========================================================================================================

Your cdk8s typescript project is ready!

cat help Print this message

Compile:
npm run compile Compile typescript code to javascript (or "yarn watch")
npm run watch Watch for changes and compile typescript in the background
npm run build Compile + synth

Synthesize:
npm run synth Synthesize k8s manifests from charts to dist/ (ready for 'kubectl apply -f')

Deploy:
kubectl apply -f dist/*.k8s.yaml

Upgrades:
npm run import Import/update k8s apis (you should check-in this directory)
npm run upgrade Upgrade cdk8s modules to latest version
npm run upgrade:next Upgrade cdk8s modules to latest "@next" version (last commit)

========================================================================================================
Loading