Skip to content

Commit

Permalink
added charts for k8 and fixed jenkins for deploys
Browse files Browse the repository at this point in the history
  • Loading branch information
specular-rhoop committed Mar 7, 2024
1 parent 5582690 commit 6dcf804
Show file tree
Hide file tree
Showing 17 changed files with 975 additions and 8 deletions.
79 changes: 71 additions & 8 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pipeline {
// checkout git
checkout scmGit(
userRemoteConfigs: [
[ credentialsId: 'jenkins-specular', url: 'github.com:SpecularL2/specular.git']
[ credentialsId: 'jenkins-specular', url: 'github.com:SpecularL2/specular-build-test.git']
],
branches: [[name: '*/PR-*'], [name: '*/develop']],
)
Expand All @@ -23,43 +23,106 @@ pipeline {
sh 'chmod -R 777 workspace'
}
}
stage('create build image') {
stage('create build image for pr') {
when {
not {
branch 'develop'
}
}
steps{
script {
docker.withRegistry('https://792926601177.dkr.ecr.us-east-2.amazonaws.com', 'ecr:us-east-2:builder') {
docker.build(
registry + ":e2e-pr-$BUILD_NUMBER",
registry + ":e2e-pr-$GIT_COMMIT",
"-f docker/e2e.Dockerfile ."
)
}

}
}
}
stage('create build image for devnet') {
when {
branch 'develop'
}
steps{
script {
docker.withRegistry('https://792926601177.dkr.ecr.us-east-2.amazonaws.com', 'ecr:us-east-2:builder') {
def e2eContainer = docker.build(
registry + ":e2e-$GIT_COMMIT",
"-f docker/e2e.Dockerfile ."
)
e2eContainer.push()
e2eContainer.push("e2e-latest")
}

}
}
}
stage('e2e-test') {
when {
not {
branch 'develop'
}
}
parallel {
stage('transactions') {
steps {
sh "docker run -w /specular/workspace 792926601177.dkr.ecr.us-east-2.amazonaws.com/specular-platform:e2e-pr-$BUILD_NUMBER ../sbin/run_e2e_tests.sh transactions"
sh "docker run -w /specular/workspace 792926601177.dkr.ecr.us-east-2.amazonaws.com/specular-platform:e2e-pr-$GIT_COMMIT ../sbin/run_e2e_tests.sh transactions"
}
}
stage('deposit') {
steps {
sh "docker run -w /specular/workspace 792926601177.dkr.ecr.us-east-2.amazonaws.com/specular-platform:e2e-pr-$BUILD_NUMBER ../sbin/run_e2e_tests.sh deposit"
sh "docker run -w /specular/workspace 792926601177.dkr.ecr.us-east-2.amazonaws.com/specular-platform:e2e-pr-$GIT_COMMIT ../sbin/run_e2e_tests.sh deposit"
}
}
stage('erc20') {
steps {
sh "docker run -w /specular/workspace 792926601177.dkr.ecr.us-east-2.amazonaws.com/specular-platform:e2e-pr-$BUILD_NUMBER ../sbin/run_e2e_tests.sh erc20"
sh "docker run -w /specular/workspace 792926601177.dkr.ecr.us-east-2.amazonaws.com/specular-platform:e2e-pr-$GIT_COMMIT ../sbin/run_e2e_tests.sh erc20"
}
}
stage('withdraw') {
steps {
sh "docker run -w /specular/workspace 792926601177.dkr.ecr.us-east-2.amazonaws.com/specular-platform:e2e-pr-$BUILD_NUMBER ../sbin/run_e2e_tests.sh withdraw"
sh "docker run -w /specular/workspace 792926601177.dkr.ecr.us-east-2.amazonaws.com/specular-platform:e2e-pr-$GIT_COMMIT ../sbin/run_e2e_tests.sh withdraw"
}
}
}
}

stage('publish images') {
when {
branch "develop"
}
steps {
script {
docker.withRegistry('https://792926601177.dkr.ecr.us-east-2.amazonaws.com', 'ecr:us-east-2:builder') {
def spcContainer = docker.build(registry + ":$GIT_COMMIT", "-f docker/specular.Dockerfile .")
spcContainer.push()
spcContainer.push("specular-latest")
}
}
}
}
stage('upgrade helm') {
when {
branch "develop"
}
steps {
dir('charts/specular') {
withCredentials([[
$class: 'AmazonWebServicesCredentialsBinding',
credentialsId: "builder",
accessKeyVariable: 'AWS_ACCESS_KEY_ID',
secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
]]) {
script {
sh '''
aws eks update-kubeconfig --region us-east-2 --name specular-staging-eks
kubectl config use-context arn:aws:eks:us-east-2:792926601177:cluster/specular-staging-eks
helm upgrade specular . -n specular --set image.tag=$GIT_COMMIT'''
}
}
}
}
}
}
}
6 changes: 6 additions & 0 deletions charts/specular/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: specular
description: Specular L2 Network
version: 0.0.1
apiVersion: v2
keywords:
- specular
16 changes: 16 additions & 0 deletions charts/specular/templates/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

apiVersion: v1
kind: ConfigMap
metadata:
name: specular-config
data:
{{- range $i, $value := .Values.configMaps }}
{{ $i }}: |
{{- range $ii, $item := $value }}
{{ $item.name }}={{ $item.value }}
{{- end }}
{{- end }}
{{- range $name, $value := .Values.jsonMaps }}
{{ $name }}: |
{{ $value | toJson }}
{{- end }}
49 changes: 49 additions & 0 deletions charts/specular/templates/debug-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{{- if .Values.enabled.debug -}}
apiVersion: v1
kind: Pod
metadata:
name: debug-container
namespace: specular
spec:
# initContainers:
# - name: wait-for-sp-geth
# image: busybox:latest
# command: ["sh", "-c", "echo '{{ .Values.image.tag }}' > /tmp/release"]
# volumeMounts:
# - mountPath: /tmp
# name: {{ .Values.volume.efs.name }}
containers:
- name: debug-container
image: nginx
volumeMounts:
- mountPath: /tmp/workspace
name: {{ .Values.volume.efs.name }}
{{- range $i, $value := .Values.volume.configVolumeMounts.paths }}
- name: {{ $.Values.volume.configVolumeMounts.name }}
mountPath: /tmp/workspace/{{ $value }}
subPath: {{ $value }}
{{- end }}
{{- if not .Values.generator.deploy }}
{{- range $i, $value := .Values.volume.secrets }}
- name: secret-volume
mountPath: /tmp/workspace/{{ $value.file }}
subPath: {{ $value.file }}
readOnly: true
{{- end }}
{{- end }}
workingDir: /tmp/workspace
restartPolicy: OnFailure
volumes:
- name: {{ .Values.volume.efs.name }}
persistentVolumeClaim:
claimName: {{ .Values.volume.efs.name }}
- name: {{ .Values.volume.configVolumeMounts.name }}
configMap:
name: {{ .Values.volume.configVolumeMounts.name }}
{{- if not .Values.generator.deploy }}
- name: secret-volume
secret:
secretName: l2-secrets
{{- end }}
status: {}
{{- end -}}
45 changes: 45 additions & 0 deletions charts/specular/templates/generator-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
io.specular.network/sp-network: "true"
io.specular.service: generator
name: generator
spec:
containers:
- name: generator
command: ["bash", "-c", "{{ .Values.generator.command }}"]
image: "{{ .Values.image.registry }}/{{ .Values.image.name }}:{{ .Values.image.tag }}"
resources:
{{- .Values.default_resources | toYaml | nindent 10 }}
volumeMounts:
- mountPath: {{ .Values.volume.efs.mountPath }}
name: {{ .Values.volume.efs.name }}
{{- range $i, $value := .Values.volume.configVolumeMounts.paths }}
- name: {{ $.Values.volume.configVolumeMounts.name }}
mountPath: {{ $.Values.volume.efs.mountPath }}/{{ $value }}
subPath: {{ $value }}
{{- end }}
{{- if not .Values.generator.deploy }}
{{- range $i, $value := .Values.volume.secrets }}
- name: secret-volume
mountPath: {{ $.Values.volume.efs.mountPath }}/{{ $value.file }}
subPath: {{ $value.file }}
readOnly: true
{{- end }}
{{- end }}
restartPolicy: Never
volumes:
- name: {{ .Values.volume.efs.name }}
persistentVolumeClaim:
claimName: {{ .Values.volume.efs.name }}
- name: {{ .Values.volume.configVolumeMounts.name }}
configMap:
name: {{ .Values.volume.configVolumeMounts.name }}
{{- if not .Values.generator.deploy }}
- name: secret-volume
secret:
secretName: l2-secrets
{{- end }}
status: {}
31 changes: 31 additions & 0 deletions charts/specular/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: specular-ingress
namespace: specular
annotations:

# nginx.ingress.kubernetes.io/ssl-redirect: "true"
# nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
spec:
ingressClassName: nginx
rules:
- host: {{ .Values.environment }}.specular.network
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: sp-geth
port:
number: 4011
- path: /ws
pathType: Prefix
backend:
service:
name: sp-geth
port:
number: 4012
65 changes: 65 additions & 0 deletions charts/specular/templates/l1-geth-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{{- if .Values.enabled.l1Geth -}}
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
io.specular.network/sp-network: "true"
io.specular.service: l1-geth
name: l1-geth
spec:
initContainers:
- name: wait-for-sp-generator
image: busybox:latest
command: ["sh", "-c", "until [ -f /tmp/.generate_secrets.sh.lock ]; do sleep 2; done"]
volumeMounts:
- mountPath: /tmp
name: {{ .Values.volume.efs.name }}
containers:
- name: l1-geth
command: ["bash", "-c", "../sbin/entrypoint.sh start start_l1.sh -c -d -w -y"]
image: "{{ .Values.image.registry }}/{{ .Values.image.name }}:{{ .Values.image.tag }}"
livenessProbe:
exec:
command: ["sh", "-c", "test -e /specular/workspace/.start_l1.sh.lock"]
failureThreshold: 300
initialDelaySeconds: 60
periodSeconds: 1
lifecycle:
preStop:
exec:
command: ["sh", "-c", "rm -f /specular/workspace/.*.lock"]
ports:
- containerPort: 8545
hostPort: 8545
protocol: TCP
resources:
{{- .Values.default_resources | toYaml | nindent 10 }}
tty: true
volumeMounts:
- mountPath: {{ .Values.volume.efs.mountPath }}
name: {{ .Values.volume.efs.name }}
{{- range $i, $value := .Values.volume.configVolumeMounts.paths }}
- name: {{ $.Values.volume.configVolumeMounts.name }}
mountPath: {{ $.Values.volume.efs.mountPath }}/{{ $value }}
subPath: {{ $value }}
{{- end }}
{{- if not .Values.generator.deploy }}
{{- range $i, $value := .Values.volume.secrets }}
- name: secret-volume
mountPath: {{ $.Values.volume.efs.mountPath }}/{{ $value.file }}
subPath: {{ $value.file }}
readOnly: true
{{- end }}
{{- end }}
workingDir: {{ .Values.volume.efs.mountPath }}
restartPolicy: Always
volumes:
- name: {{ .Values.volume.efs.name }}
persistentVolumeClaim:
claimName: {{ .Values.volume.efs.name }}
- name: {{ .Values.volume.configVolumeMounts.name }}
configMap:
name: {{ .Values.volume.configVolumeMounts.name }}
status: {}
{{- end -}}
19 changes: 19 additions & 0 deletions charts/specular/templates/l1-geth-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- if .Values.enabled.l1Geth -}}
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
io.specular.service: l1-geth
name: l1-geth
spec:
ports:
- name: "8545"
port: 8545
targetPort: 8545
- name: "8546"
port: 8546
targetPort: 8546
selector:
io.specular.service: l1-geth
{{- end -}}
Loading

0 comments on commit 6dcf804

Please sign in to comment.