Skip to content

Instantly share code, notes, and snippets.

View myclau's full-sized avatar

Matthias Lau myclau

View GitHub Profile
@myclau
myclau / AWS_init_terrafrom_proj_script
Created September 13, 2022 02:56
Terrafrom init script for new project
#!/bin/bash
DEFAULT_BACKEND_S3BUCKET="<s3-bucket-name>"
DEFAULT_BACKEND_PROFILE="<s3-bucket-aws-profile>"
DEFAULT_BACKEND_REGION="<s3-bucket-region>"
DEFAULT_TERRAFORM_PROFILE="<default-aws-profile>"
DEFAULT_TERRAFORM_REGION="<default-aws-region>"
GIT_REMOTE_URL=$(git config --get remote.origin.url)
@myclau
myclau / gitlab_api-powershell.ps1
Created June 24, 2020 02:40
gitlab_api-powershell
# get project id
$response=Invoke-WebRequest -Method GET -Headers @{"PRIVATE-TOKEN"="$apitoken";"Content-Type"="application/json"} -Uri "$gitremoteDomain/api/v4/projects"
$content=ConvertFrom-Json $([String]::new($response.Content))
foreach ($c in $content){
if($c.name -eq $projectname){
$projectid = $c.id
break
}
}
@myclau
myclau / find_relative_path
Created June 17, 2020 05:21
find_relative_path
#powershell
# just put the uri without domain in to this variable
$gitremoteUri="xxxx/xxxxxt/xxx"
$relativeRootPath=""
$gitremoteTreeLevel=$gitremoteUri.split('/').length
for ($i=0; $i -lt $gitremoteTreeLevel ; $i++){
$relativeRootPath+="../"
}
@myclau
myclau / Drain k8s node
Last active June 9, 2020 06:57
Drain k8s node
#find node names
kubectl get no
set NODENAME=xxxxxxxxxxxxxxx
kubectl cordon $NODENAME
#check pod on node
kubectl get pods --all-namespaces --field-selector spec.nodeName=$NODENAME -o wide
@myclau
myclau / maven docker build image sample
Last active June 2, 2020 08:42
maven docker build image sample
#
# Build stage
#
FROM maven:3.6.0-jdk-11-slim AS build
COPY src /home/app/src
COPY pom.xml /home/app
RUN mvn -f /home/app/pom.xml clean package
#
# Package stage
@myclau
myclau / azure_move_disk_toother_region.ps1
Last active June 24, 2019 01:34
Azure move disk to different region
#Provide the subscription Id where snapshot is created
$SubscriptionId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
#Provide the name of your resource group where snapshot is created
$resourceGroupName="rgname"
#Provide the snapshot name
$SnapshotName = "snapshotname"
#Provide Shared Access Signature (SAS) expiry duration in seconds e.g. 3600.
#Know more about SAS here: https://docs.microsoft.com/en-us/azure/storage/storage-dotnet-shared-access-signature-part-1
$sasExpiryDuration = "3600"
#Provide storage account name where you want to copy the snapshot.
function add-https-support(){
if ("TrustAllCertsPolicy" -as [type]) {
#"TrustAllCertsPolicy is already loaded"
}else{
#add https support
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
@myclau
myclau / configmap
Created December 5, 2018 09:39
fluentd-graylog-k8s
<match fluent.**>
@type null
</match>
<source>
@type tail
@id in_tail_container_logs
limit_recently_modified 1s
path /var/log/containers/*.log
pos_file /var/rancher-fluentd/db/fluentd-containers.log.pos
@myclau
myclau / remove image in registory v2
Created November 27, 2018 00:51
Remove image in registry v2
1. Login to the container
`docker exec -it registry sh`
2. Define variables matching your container and container version:
```export NAME="google/cadvisor"
export VERSION="v0.24.1"```
3. Move to the the registry directory:
`cd /var/lib/registry/docker/registry/v2`
@myclau
myclau / 0_kubectl related script
Last active June 2, 2023 02:13
kubectl related script