Skip to content

Commit c5b91d5

Browse files
committed
Kubernetes: Init All in one buddle of Kubernetes
* Deployment manifest files * Jenkins deployments & confiqurations * Kubernetes Ingress files * Realtime projects manifest files * Helm charts for any application * End to End Manifest files for any applications * Includes AWS ELK Stack (Elasticsearch, Logstash, Kibana) * Network service confiqirations templates * Application monitoring templates for any applications * Complete application launch manifest files for realtime projects Signed-off-by: NotHarshhaa <[email protected]>
0 parents  commit c5b91d5

File tree

185 files changed

+60484
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

185 files changed

+60484
-0
lines changed

Diff for: Jenkins/Jenkins-CD/Dockerfile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Dynamic build Jenkins Agent Pod to execute deployment steps
2+
FROM amazonlinux
3+
RUN yum install git -y && \
4+
yum install wget -y && \
5+
yum install tar -y && \
6+
yum install gzip -y
7+
8+
RUN mkdir /root/.ssh && \
9+
mkdir -p /opt/java && \
10+
mkdir /opt/app
11+
COPY ./id_rsa /root/.ssh/id_rsa
12+
RUN chmod 700 /root/.ssh && \
13+
chmod 600 /root/.ssh/id_rsa && \
14+
chown -R root:root /root/.ssh && \
15+
ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts
16+
17+
RUN curl -LO https://dl.k8s.io/release/v1.22.0/bin/linux/amd64/kubectl && \
18+
chmod +x kubectl && \
19+
mv kubectl /usr/local/bin/
20+
RUN wget https://get.helm.sh/helm-v3.7.0-linux-amd64.tar.gz && \
21+
tar xzf helm-v3.7.0-linux-amd64.tar.gz -C /tmp && \
22+
mv /tmp/linux-amd64/helm /usr/local/bin/ && \
23+
rm helm-v3.7.0-linux-amd64.tar.gz
24+
RUN /usr/local/bin/helm plugin install https://github.com/belitre/helm-push-artifactory-plugin --version v0.3.0

Diff for: Jenkins/Jenkins-CD/Dockerfile.1

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Apache Tomcat Base Image
2+
FROM amazonlinux
3+
ENV JAVA_HOME /opt/jdk11
4+
ENV PATH $PATH:/opt/jdk11/bin
5+
RUN yum install wget -y && \
6+
yum install gzip -y && \
7+
yum install tar -y
8+
RUN wget https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz && \
9+
tar zxf openjdk-11+28_linux-x64_bin.tar.gz && \
10+
mv jdk-11 /opt/jdk11
11+
RUN wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.82/bin/apache-tomcat-8.5.82.tar.gz && \
12+
tar zxf apache-tomcat-8.5.82.tar.gz && \
13+
mv apache-tomcat-8.5.82 /opt/tomcat
14+
CMD ["/opt/tomcat/bin/catalina.sh", "run"]

Diff for: Jenkins/Jenkins-CD/Jenkinsfile

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
def label = "deploy"
2+
podTemplate(label: label, yaml: """
3+
apiVersion: v1
4+
kind: Pod
5+
metadata:
6+
labels:
7+
name: deploy
8+
spec:
9+
serviceAccount: jenkins-agent-sa
10+
containers:
11+
- name: deploy
12+
image: dpthub/eddeployagent
13+
command:
14+
- cat
15+
tty: true
16+
"""
17+
) {
18+
node (label) {
19+
20+
stage ('Checkout SCM'){
21+
git url: 'https://[email protected]/dptrealtime/loginapp-cicd-deployment.git', branch: 'dev'
22+
}
23+
24+
stage ('Helm Chart') {
25+
container('deploy') {
26+
dir('charts') {
27+
withCredentials([usernamePassword(credentialsId: 'jfrog', usernameVariable: 'username', passwordVariable: 'password')]) {
28+
sh '/usr/local/bin/helm repo add dptweb-helm-local https://edwikifacts.jfrog.io/artifactory/dptweb-helm-local --username $username --password $password'
29+
sh "/usr/local/bin/helm repo update"
30+
sh "/usr/local/bin/helm install dptweb-dev --namespace dev -f values.yaml ."
31+
sh "/usr/local/bin/helm list -a --namespace dev"
32+
}
33+
}
34+
}
35+
}
36+
}
37+
}

Diff for: Jenkins/Jenkins-CD/serviceaccount.yaml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: jenkins-agent-sa
5+
---
6+
apiVersion: rbac.authorization.k8s.io/v1
7+
kind: ClusterRole
8+
metadata:
9+
name: jenkins-agent
10+
labels:
11+
"app.kubernetes.io/name": 'jenkins-agent'
12+
rules:
13+
- apiGroups: [""]
14+
resources: ["pods"]
15+
verbs: ["create","delete","get","list","patch","update","watch"]
16+
- apiGroups: [""]
17+
resources: ["pods/exec"]
18+
verbs: ["create","delete","get","list","patch","update","watch"]
19+
- apiGroups: [""]
20+
resources: ["pods/log"]
21+
verbs: ["get","list","watch"]
22+
- apiGroups: [""]
23+
resources: ["secrets"]
24+
verbs: ["create","delete","get","list","patch","update","watch"]
25+
---
26+
apiVersion: rbac.authorization.k8s.io/v1
27+
kind: ClusterRoleBinding
28+
metadata:
29+
name: jenkins-agent-role-binding
30+
namespace: default
31+
roleRef:
32+
apiGroup: rbac.authorization.k8s.io
33+
kind: ClusterRole
34+
name: jenkins-agent
35+
subjects:
36+
- kind: ServiceAccount
37+
name: jenkins-agent-sa
38+
namespace: default
39+
---
40+
apiVersion: v1
41+
kind: Secret
42+
metadata:
43+
name: jenkins-agent-secret
44+
annotations:
45+
kubernetes.io/service-account.name: jenkins-agent-sa
46+
type: kubernetes.io/service-account-token

Diff for: Jenkins/Jenkins-CI/Dockerfile

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM amazonlinux
2+
ENV JAVA_HOME /opt/java/jdk11
3+
ENV M2_HOME /opt/maven
4+
ENV PATH $PATH:$JAVA_HOME/bin:$M2_HOME/bin
5+
RUN yum install git -y && \
6+
yum install wget -y && \
7+
yum install tar -y && \
8+
yum install gzip -y && \
9+
amazon-linux-extras install docker -y
10+
11+
RUN mkdir /root/.ssh && \
12+
mkdir -p /opt/java && \
13+
mkdir /opt/app
14+
COPY ./id_rsa /root/.ssh/id_rsa
15+
RUN chmod 700 /root/.ssh && \
16+
chmod 600 /root/.ssh/id_rsa && \
17+
chown -R root:root /root/.ssh && \
18+
ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts
19+
20+
RUN wget https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz && \
21+
tar xzf openjdk-11+28_linux-x64_bin.tar.gz -C /tmp && \
22+
mv /tmp/jdk-11 $JAVA_HOME && \
23+
rm openjdk-11+28_linux-x64_bin.tar.gz
24+
25+
RUN wget https://archive.apache.org/dist/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz && \
26+
tar xzf apache-maven-3.8.6-bin.tar.gz -C /tmp && \
27+
mv /tmp/apache-maven-3.8.6 $M2_HOME && \
28+
rm apache-maven-3.8.6-bin.tar.gz
29+
RUN curl -LO https://dl.k8s.io/release/v1.22.0/bin/linux/amd64/kubectl && \
30+
chmod +x kubectl && \
31+
mv kubectl /usr/local/bin/
32+
RUN wget https://get.helm.sh/helm-v3.7.0-linux-amd64.tar.gz && \
33+
tar xzf helm-v3.7.0-linux-amd64.tar.gz -C /tmp && \
34+
mv /tmp/linux-amd64/helm /usr/local/bin/ && \
35+
rm helm-v3.7.0-linux-amd64.tar.gz
36+
RUN /usr/local/bin/helm plugin install https://github.com/belitre/helm-push-artifactory-plugin --version v0.3.0

Diff for: Jenkins/Jenkins-CI/Jenkinsfile

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
def label = "build"
2+
podTemplate(label: label, yaml: """
3+
apiVersion: v1
4+
kind: Pod
5+
metadata:
6+
labels:
7+
app: build
8+
spec:
9+
containers:
10+
- name: build
11+
image: dpthub/edbuild
12+
command:
13+
- cat
14+
tty: true
15+
volumeMounts:
16+
- name: dockersock
17+
mountPath: /var/run/docker.sock
18+
volumes:
19+
- name: dockersock
20+
hostPath:
21+
path: /var/run/docker.sock
22+
"""
23+
) {
24+
node (label) {
25+
26+
stage ('Checkout SCM'){
27+
git url: 'https://[email protected]/dptrealtime/edweb-login-integration.git', branch: 'master'
28+
container('build') {
29+
stage('Build a Maven project') {
30+
sh 'mvn clean deploy -s settings.xml'
31+
}
32+
}
33+
}
34+
35+
stage ('Docker Build'){
36+
container('build') {
37+
stage('Build Image') {
38+
docker.withRegistry( 'https://registry.hub.docker.com', 'docker' ) {
39+
def customImage = docker.build("dpthub/webapp")
40+
customImage.push()
41+
}
42+
}
43+
}
44+
}
45+
46+
stage ('Helm Chart') {
47+
container('build') {
48+
dir('charts') {
49+
withCredentials([usernamePassword(credentialsId: 'jfrog', usernameVariable: 'username', passwordVariable: 'password')]) {
50+
sh '/usr/local/bin/helm package webapp'
51+
sh '/usr/local/bin/helm push-artifactory webapp-1.0.tgz https://edwikifacts.jfrog.io/artifactory/edweb-helm-local --username $username --password $password'
52+
}
53+
}
54+
}
55+
}
56+
}
57+
}

Diff for: Jenkins/Jenkins-CI/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
1. Create Builder Image
2+
2. Create Service Account
3+
3. Install Plugins
4+
3.1 Kubernetes
5+
3.2 jfrog
6+
3.3 docker
7+
3.4 maven
8+
3.5 git
9+
4. Credentials
10+
Bitbucket - ssh keys (in the image)
11+
jfrog - admin / Admin123 [email protected] / Admin@123
12+
docker - dpthub / HubD0ck3R
13+
6.

Diff for: Jenkins/Jenkins-in-Pod/deployment.yaml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Deploy Jenkins application with Liveness and Readiness Probe
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: jenkins
6+
namespace: default
7+
labels:
8+
app: jenkins
9+
spec:
10+
replicas: 1
11+
selector:
12+
matchLabels:
13+
app: jenkins
14+
template:
15+
metadata:
16+
labels:
17+
app: jenkins
18+
spec:
19+
serviceAccountName: jenkins-admin
20+
securityContext:
21+
fsGroup: 1000
22+
runAsUser: 1000
23+
containers:
24+
- name: jenkins
25+
image: docker.io/jenkins/jenkins:lts-jdk11
26+
ports:
27+
- name: httpport
28+
containerPort: 8080
29+
- name: jnlpport
30+
containerPort: 50000
31+
livenessProbe:
32+
httpGet:
33+
path: "/login"
34+
port: 8080
35+
initialDelaySeconds: 30
36+
periodSeconds: 10
37+
timeoutSeconds: 5
38+
failureThreshold: 5
39+
readinessProbe:
40+
httpGet:
41+
path: "/login"
42+
port: 8080
43+
initialDelaySeconds: 30
44+
periodSeconds: 10
45+
timeoutSeconds: 5
46+
failureThreshold: 3

0 commit comments

Comments
 (0)