Skip to content

Instantly share code, notes, and snippets.

View naturalett's full-sized avatar

Lidor Ettinger naturalett

View GitHub Profile
@Library('ni-utils') _
//service name is extrapolated from repository name
def svcName = currentBuild.rawBuild.project.parent.displayName
//get pod template definition
def pod = libraryResource 'org/foo/k8s-pod-template.groovy'
def image_dependencies =
'''
- name: fermium-alpine
@naturalett
naturalett / renderTemplate.groovy
Created December 22, 2022 22:40
renderTemplate
import groovy.text.StreamingTemplateEngine
def call(input, variables) {
def engine = new StreamingTemplateEngine()
return engine.createTemplate(input).make(variables).toString()
}
@naturalett
naturalett / aws-cli.yaml
Created December 21, 2022 22:35
Jenkins shared library resource aws-cli
apiVersion: v1
kind: Pod
metadata:
labels:
app: aws-cli
buildnode: "true"
spec:
serviceAccountName: jenkins
nodeSelector:
kops.k8s.io/instancegroup: buildnodes
@naturalett
naturalett / commonPipeline.groovy
Last active December 17, 2023 15:12
commonPipelineWorkshop
#!/usr/bin/env groovy
import groovy.text.StreamingTemplateEngine
def call(sharedLibrary, svcName, buildCommands, pod, slackChannel) {
if (pod.contains("<%")) {
pod = new StreamingTemplateEngine().createTemplate(pod).make(['' : '']).toString()
}
def podLabel = "${svcName}-${UUID.randomUUID().toString().substring(0,8)}"
pipeline {
@naturalett
naturalett / script.sh
Created November 7, 2022 17:16
terragrunt/infra/eks/script.sh
cluster_endpoint=$(aws eks describe-cluster \
--region $region_code \
--name $cluster_name \
--query "cluster.endpoint" \
--output text)
certificate_data=$(aws eks describe-cluster \
--region $region_code \
--name $cluster_name \
--query "cluster.certificateAuthority.data" \
@naturalett
naturalett / terragrunt.hcl
Created November 7, 2022 17:15
terragrunt/infra/eks/terragrunt.hcl
include "eks" {
path = "${get_path_to_repo_root()}/modules/eks/terragrunt.hcl"
}
locals {
env_vars = read_terragrunt_config(get_path_to_repo_root())
}
dependency "vpc" {
config_path = "${get_path_to_repo_root()}/infra/vpc"
@naturalett
naturalett / terragrunt.hcl
Created November 7, 2022 17:14
terragrunt/modules/eks/terragrunt.hcl
terraform {
# https://registry.terraform.io/modules/terraform-aws-modules/eks/aws/latest
source = "tfr:///terraform-aws-modules/eks/aws?version=18.27.1"
after_hook "terragrunt-read-config" {
commands = ["apply"]
execute = ["bash", "./script.sh"]
}
extra_arguments "set_env" {
commands = ["apply"]
env_vars = {
@naturalett
naturalett / terragrunt.hcl
Created November 3, 2022 22:26
terragrunt/modules/eks-managed-node-group/terragrunt.hcl
terraform {
# https://registry.terraform.io/modules/terraform-aws-modules/eks/aws/latest/submodules/eks-managed-node-group
source = "tfr:///terraform-aws-modules/eks/aws//modules/eks-managed-node-group?version=18.27.1"
}
@naturalett
naturalett / terragrunt.hcl
Created October 23, 2022 11:35
terragrunt/terragrunt.hcl (infrastructure environment variables terragrunt)
locals {
cluster_full_name = "devops-us-east-1.k8s.local"
kube_config_path = pathexpand("./${local.cluster_full_name}.config")
aws_region = "us-east-1"
bucket = "${get_env("BUCKET")}"
cluster_name = "devops"
cluster_version = "1.22"
account_id = "${get_env("ACCOUNT_ID")}"
profile = "devops"
namespaces = ["workshop"]
@naturalett
naturalett / terragrunt.hcl
Created September 22, 2022 22:09
terragrunt/infra/vpc/terragrunt.hcl
include "vpc" {
path = "${dirname(get_repo_root())}/${basename(get_repo_root())}/modules/vpc/terragrunt.hcl"
}
locals {
env_vars = read_terragrunt_config(get_path_to_repo_root())
}
inputs = {
name = local.env_vars.locals.cluster_name