Skip to content

Instantly share code, notes, and snippets.

View pjbgf's full-sized avatar
🦎

Paulo Gomes pjbgf

🦎
View GitHub Profile
@pjbgf
pjbgf / .gitconfig
Last active February 23, 2019 06:50
Setup linux dev machine
[user]
email = [email protected]
name = Paulo Gomes
# signingkey = 08523F6EF8967D22
[alias]
co = checkout
# cms = commit -S -m
cm = commit -m
d = diff
s = status
@pjbgf
pjbgf / get-hostnames.sh
Created June 29, 2018 11:05
Get all PaaS Host Names from the current Azure subscription
# return all web sites
az resource list --resource-type "Microsoft.Web/sites" --query "[].id" --output tsv |
# query azure for each resource
xargs az resource show --ids |
# define output
jq -r '.[].siteProperties.properties // .[].properties | .enabledHostNames[] // .hostNames | match("^((?!scm).)*$").string'
# return all cloud services
az resource list --resource-type "Microsoft.ClassicCompute/domainNames" --query "[].id" --output tsv |
@pjbgf
pjbgf / AKS Running Pods.json
Created May 9, 2018 22:28
Sample Kubelet Running Pods
{
"kind": "PodList",
"apiVersion": "v1",
"metadata": { },
"items": [{
"metadata": {
"name": "heapster-4637824328-zpckl", "namespace": "kube-system", "uid": "XXXXX-XXXX-XXX-XXXXXXXX", "creationTimestamp": null
}, "spec": {
"containers": [{
"name": "heapster-nanny", "image": "k8s-gcrio.azureedge.net/addon-resizer@sha256:dcec9a5c2e20b8df19f3e9eeb87d9054a9e94e71479b935d5cfdbede9ce15895", "resources": {}
@pjbgf
pjbgf / aks-metadata.json
Created May 9, 2018 22:10
Azure AKS VM metadata sample
{
"compute":
{
"location": "westeurope",
"name": "aks-nodepool1-XXXXXXXXXX-1",
"offer": "UbuntuServer",
"osType": "Linux",
"placementGroupId": "",
"platformFaultDomain": "0",
"platformUpdateDomain": "2",
@pjbgf
pjbgf / disable-automount-service-account-default.yaml
Created March 8, 2018 22:01
Disable the auto-mount for the default Service Account
apiVersion: v1
kind: ServiceAccount
metadata:
name: default
automountServiceAccountToken: false
@pjbgf
pjbgf / k8s-security-challenge1-setup.sh
Last active December 28, 2019 05:13
Kubernetes Security Challenge 1.
# Login with your Azure subscription
az login
# Register providers required within the subscription
az provider register -n Microsoft.ContainerService
az provider register -n Microsoft.Network
az provider register -n Microsoft.Compute
# Create resource group to place AKS cluster.
az group create --name k8s-security-challenge-rg --location centralus
@pjbgf
pjbgf / kubernetes-dotnetcore-deployment.yml
Created January 16, 2018 14:16
Circle CI Kubernetes Container Deployment
version: 2
jobs:
build_test_publish_image:
docker:
- image: paulinhu/netcore-docker-build:beta
environment:
ACR_NAME: akspoc
DOCKER_REGISTRY_URI: akspoc.azurecr.io
DOCKER_IMAGE_NAME_WITH_REGISTRY: akspoc.azurecr.io/template/sample-app-img
@pjbgf
pjbgf / aks-cluster-provisioning.yml
Created January 16, 2018 14:11
Circle CI config for AKS Cluster Provisioning
version: 2
jobs:
provision_cluster:
docker:
- image: azuresdk/azure-cli-python
environment:
RESOURCE_GROUP: aks-poc-euw-rg
CLUSTER_LOCATION: westeurope
CONTAINER_REPOSITORY: akspoc
@pjbgf
pjbgf / ZombieActivator.cs
Created November 13, 2017 09:31
Zombie Activator
[assembly: PreApplicationStartMethod(typeof(ZombieActivator), "Run")]
public static class ZombieActivator
{
public static void Run()
{
try
{
if (IsThisLikelyToBeProductionEnvironment())
System.Web.HttpApplication.RegisterModule(typeof(ZombieModule));
}
@pjbgf
pjbgf / WebApi_ByPassAuthorisation.cs
Created November 10, 2017 16:15
Bypassing authorisation on Web APIs
using System;
using System.Collections;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;