Skip to content

Instantly share code, notes, and snippets.

View weinong's full-sized avatar

Weinong Wang weinong

View GitHub Profile
@weinong
weinong / block-imds.yaml
Created January 4, 2024 21:23
network policy with cilium
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-egress-to-imds
spec:
podSelector: {}
policyTypes:
- Egress
egress:
- to:
Below is a markdown demo
```sh
# Navigate to aks-rp/toolkit/azureclients/pav2subscriptionclient folder in terminal
# Setup your enviroment variable
export TENANT_ID="<specify with real value>"
export CLIENT_ID="<specify with real value>"
export CLIENT_SECRET="<specify with real value>"
export VCR_MODE="RecordOnly"
@weinong
weinong / remove-all-leases.sh
Created August 4, 2022 03:48
[Azure DevOps] remove all build retentions from a group of build definitions
#!/bin/bash
INF='\n'
USER=
TOKEN=
ORG=
PROJECT=
for definitionID in (91395 100391 91349 87035 95571 64773 79297 64580 63192 64774); do
for buildID in $(az pipelines build list --org https://dev.azure.com/${ORG}/ -p ${PROJECT} --definition-ids ${definitionID} -o json | jq -r ".[].id"); do
openssl req \
-newkey rsa:2048 \
-x509 \
-nodes \
-keyout server.key \
-new \
-out server.crt \
-subj /CN=example.com \
-reqexts SAN \
-extensions SAN \
@weinong
weinong / cloud-inti.yaml
Last active July 28, 2022 17:37
azure vm with tailscale
#cloud-config
package_update: true
runcmd:
- curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/bionic.gpg | apt-key add -
- curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/bionic.list | tee /etc/apt/sources.list.d/tailscale.list
- apt-get update
- apt-get install -y tailscale
- tailscale up --authkey AUTH_KEY
@weinong
weinong / az.yaml
Last active June 8, 2025 19:22
ubuntu deployment spec
apiVersion: v1
kind: Pod
metadata:
name: az-cli
spec:
containers:
- image: mcr.microsoft.com/azure-cli
name: oidc
command:
- sleep
@weinong
weinong / create-aro.sh
Created September 30, 2021 18:03
create Azure Red Hat OpenShift cluster
#!/bin/bash
SUBSCRIPTION=''
LOCATION=eastus
RESOURCEGROUP=aro-rg
CLUSTER=cluster
az account set --subscription $SUBSCRIPTION
az group create \
@weinong
weinong / graph sp
Last active April 26, 2022 23:57
AAD samples
#!/bin/bash
urlencode() {
printf $1 'encode this'|jq -sRr @uri
}
TOKEN=$(az account get-access-token --resource-type aad-graph --query "accessToken" -o tsv)
TENANT=$(az account show --query "tenantId" -o tsv)
spName="<sp name or id>"
@weinong
weinong / cheatsheet.yaml
Created October 17, 2020 00:30
Azure Connect Day 2020
apiVersion: apps/v1
kind: Deployment
metadata:
name: node-web-app
spec:
selector:
matchLabels:
app: node-web-app
replicas: 2
template:
@weinong
weinong / Dockerfile
Created August 18, 2020 21:52
simple udp on k8s
FROM alpine
RUN apk add --no-cache netcat-openbsd
ENTRYPOINT [ "nc" ]