add kubectl deploy stage
This commit is contained in:
9
Jenkinsfile
vendored
9
Jenkinsfile
vendored
@@ -40,9 +40,16 @@ pipeline {
|
||||
}
|
||||
}
|
||||
stage('deploy') {
|
||||
environment {
|
||||
AWS_ACCESS_KEY_ID = credentials('jenkins_aws_access_key_id')
|
||||
AWS_SECRET_ACCESS_KEY = credentials('jenkins-aws_secret_access_key')
|
||||
APP_NAME = 'java-maven-app'
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
echo 'deploying docker image to EC2...'
|
||||
echo 'deploying docker image...'
|
||||
sh 'envsubst < kubernetes/deployment.yaml | kubectl apply -f -'
|
||||
sh 'envsubst < kubernetes/service.yaml | kubectl apply -f -'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
24
kubernetes/deployment.yaml
Normal file
24
kubernetes/deployment.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: $APP_NAME
|
||||
labels:
|
||||
app: $APP_NAME
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: $APP_NAME
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: $APP_NAME
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: my-registry-key
|
||||
containers:
|
||||
- name: $APP_NAME
|
||||
image: nanajanashia/demo-app:$IMAGE_NAME
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
11
kubernetes/service.yaml
Normal file
11
kubernetes/service.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: $APP_NAME
|
||||
spec:
|
||||
selector:
|
||||
app: $APP_NAME
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 80
|
||||
targetPort: 8080
|
||||
Reference in New Issue
Block a user