Skip to content

Instantly share code, notes, and snippets.

View initcron's full-sized avatar

Gourav Shah initcron

View GitHub Profile
metadata:
annotations:
argocd-image-updater.argoproj.io/git-branch: main
argocd-image-updater.argoproj.io/image-list: myimage=xxxxxx/vote
argocd-image-updater.argoproj.io/myimage.allow-tags: regexp:^[0-9a-f]{7}$
argocd-image-updater.argoproj.io/myimage.ignore-tags: latest, dev
argocd-image-updater.argoproj.io/myimage.update-strategy: latest
argocd-image-updater.argoproj.io/myimage.kustomize.image-name: schoolofdevops/vote
argocd-image-updater.argoproj.io/myimage.force-update: "true"
argocd-image-updater.argoproj.io/write-back-method: git:secret:argocd/git-creds
@initcron
initcron / Jenkinsfile
Created October 18, 2024 05:46
Jenkinsfile snippet with an example of a stage which is run on multiple nodes using matrix directive
pipeline {
agent none
stages {
stage('Run on multiple nodes') {
matrix {
axes {
axis {
name 'AGENT'
values 'node1', 'node2', 'node3'
}
@initcron
initcron / jenkins_k8s_smoketest
Created October 17, 2024 03:53
Jenkinsfile Snippet to Smoke Test Kubetnetes Agent Configuration
pipeline {
agent {
kubernetes {}
}
stages {
stage('Test') {
steps {
sh 'echo Hello from Kubernetes Agent!'
}
}
@initcron
initcron / Dockerfile
Created October 16, 2024 09:40
Single Stage Dockerfile for Sysfoo App
FROM maven:3.9.6-eclipse-temurin-17 AS build
WORKDIR /app
COPY . .
RUN mvn package -DskipTests
RUN mv /app/target/sysfoo-*.jar sysfoo.jar
EXPOSE 8080
CMD ["java", "-jar", "sysfoo.jar"]

Approach to Avoid Redundant Jenkins Builds

  1. Use GitHub Merge Commit Validation When PR1 is merged into the base branch, instead of manually merging it into PR2, you can let Jenkins handle it through merge commit validation. This ensures that Jenkins checks are only triggered if the combination of PR2 + base branch requires validation. Solution:

Configure Jenkins to trigger builds only on the merge of the PR branch with the latest base branch. Example: PR2 will be validated only for changes introduced in its branch + any new changes from the main branch after PR1's merge. Jenkinsfile Example:

@initcron
initcron / list_k8s_services.py
Created September 5, 2024 16:05
Show the CoreDNS Service Entries in Tabular Format
from kubernetes import client, config
from prettytable import PrettyTable
# Load kube config from the default location (~/.kube/config)
config.load_kube_config()
# Initialize the Kubernetes API client
v1 = client.CoreV1Api()
# Create a table for displaying the output
@initcron
initcron / vote-deploy.yaml
Created September 5, 2024 05:25
Vote Deployment with Resource Spec
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
role: vote
name: vote
spec:
replicas: 4
selector:
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
role: vote
name: vote
spec:
replicas: 4
selector:
@initcron
initcron / vote-ing.yaml
Created September 3, 2024 05:02
Ingress Rule for vote.example.com to point to vote service in instavote namespace.
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: vote
namespace: instavote
spec:
ingressClassName: nginx
rules:
- host: vote.example.com