Skip to content

Instantly share code, notes, and snippets.

@leitu
leitu / istio.yaml
Created August 10, 2023 00:18
istio with 1.14.x to implement canary cookie
apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
name: gw
namespace: test
spec:
selector:
app: istio-ingressgateway
istio: ingressgateway
servers:
@leitu
leitu / main.tf
Created October 28, 2019 00:35
terraform v12.x count and for_each are using together
data "azurerm_client_config" "current" {}
resource "azurerm_key_vault" "keyvault" {
count = "${length(var.vaultnames)}"
name = "${var.servicename}-${var.vaultnames[count.index]}"
location = "${var.keyvault_location}"
resource_group_name = "${var.keyvault_resource_group}"
tenant_id = "${data.azurerm_client_config.current.tenant_id}"
sku_name = "standard"
@leitu
leitu / check_log.go
Created March 26, 2019 00:18
paractise for coding
package main
import (
"fmt"
"io/ioutil"
"strings"
)
const data = `66.249.65.159 - - [06/Nov/2014:19:10:38 +0600] "GET /news/53f8d72920ba2744fe873ebc.html HTTP/1.1" 404 177
66.249.65.3 - - [06/Nov/2014:19:11:24 +0600] "GET /?q=%E0%A6%AB%E0%A6%BE%E0%A7%9F%E0%A6%BE%E0%A6%B0 HTTP/1.1" 200 4223"
# List pods which has CONSUL_HOST
kubectl get pods -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.containers[*].env[?(@.name=="CONSUL_HOST")].value}{"\n"}{end}' | awk ' NF==2 {print $0} '
# List deployment which has CONSUL_HOST
kubectl get deployment -o jsonpath="{range .items[*]}{.metadata.name}{'\t'}{.spec.template.spec.containers[*].env[*].name}{'\n'}{end}" | grep "CONSUL_HOST"
# Patch deployment env
kubectl patch deployment xyz-deployment -p '{"spec":{"template":{"spec":{"containers":[{"name":"xyz", "env":[{"name":"HTTP_PROXY", "value":"xyz-proxy.exampe.com"}]}]}}}}}'
# List pods which has CONSUL_HOST
kubectl get pods -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.containers[*].env[?(@.name=="CONSUL_HOST")].value}{"\n"}{end}' | awk ' NF==2 {print $0} '
# List deployment which has CONSUL_HOST
kubectl get deployment -o jsonpath="{range .items[*]}{.metadata.name}{'\t'}{.spec.template.spec.containers[*].env[*].name}{'\n'}{end}" | grep "CONSUL_HOST"
@leitu
leitu / Makefile
Created October 22, 2018 06:41 — forked from cjbarker/Makefile
Makefile for cross-compiling Golang. Just update BINARY var in Makefile and create empty vars in main.go for Version and Build
# ########################################################## #
# Makefile for Golang Project
# Includes cross-compiling, installation, cleanup
# ########################################################## #
# Check for required command tools to build or stop immediately
EXECUTABLES = git go find pwd
K := $(foreach exec,$(EXECUTABLES),\
$(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH)))
@leitu
leitu / check proxy
Created August 22, 2018 05:54
did some changes to pass shellcheck
#!/bin/bash
PROXYS='proxy.txt'
PROXY_TYPE='http'
CHECK_URL='https://api.ipify.org?format=json'
MAX_CONNECT=10
GOOD_ARR=()
FAIL_ARR=()
GOOD=0
FAIL=0
@leitu
leitu / jenkinsfile
Last active January 19, 2018 05:25
pipeline {
agent any
parameters {
string(name: 'COOKBOOKS', defaultVaule: "[jenkins,common,base]", description:"Add your cookbooks as []")
}
stages {
stage('fetch target chef') {
steps {
git 'ssh://[email protected]/leitu/chef-cookbook.git'
}
@leitu
leitu / checkJenkins.sh
Created January 13, 2018 01:31 — forked from julianchurchill/checkJenkins.sh
A bash script to query a Jenkins server. Use like this: 'checkJenkins.sh <jobname>' and it will query the server with the given job name every 30s. Use like this: 'checkJenkins.sh <jobname> tmux' and it will query the server once and output tmux coloured messages appropriate to display in a tmux status bar. E.g. add this to your .tmux.conf 'set …
#!/bin/bash
CONSOLE_RED="\033[2;31m"
CONSOLE_GREEN="\033[2;32m"
CONSOLE_CLEAR="\033[0m"
JENKINS_SERVER=http://my_jenkins_server
JOB=$1
JOB_QUERY=/job/${JOB}
jenkins_script env_name do
command <<-EOH.gsub(/^ {8}/, '')
import jenkins.model.*
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.domains.*
import com.cloudbees.jenkins.plugins.awscredentials.*
domain = Domain.global()
store = Jenkins.instance.getExtensionList('com.cloudbees.plugins.credentials.SystemCredentialsProvider')[0].getStore()
credentials = new AWSCredentialsImpl(