Skip to content

Instantly share code, notes, and snippets.

View iamNoah1's full-sized avatar
🐡

Noah Ispas iamNoah1

🐡
View GitHub Profile
@iamNoah1
iamNoah1 / create-aks-cluster.sh
Last active November 22, 2020 19:24
Create Azure Kubernetes with Azure CLI
az group create --name aks2akvrg --location eastus
az aks create --resource-group aks2akvrg --name myk8s --node-count 1 --generate-ssh-keys --enable-managed-identity --network-plugin azure
az aks get-credentials --resource-group aks2akvrg --name myk8s
@iamNoah1
iamNoah1 / create-azure-key-vault.sh
Last active November 21, 2020 10:58
Create Azure Key Vault with Azure CLI
az keyvault create --name "myk8skv" --resource-group "aks2akvrg" --location eastus
az keyvault secret set --vault-name "myk8skv" --name "ExamplePassword" --value "hVFkk965BuUv"
@iamNoah1
iamNoah1 / install-azure-csi.sh
Last active September 13, 2022 14:16
install csi secret store provider for azure
helm repo add csi-secrets-store-provider-azure https://azure.github.io/secrets-store-csi-driver-provider-azure/charts
helm install csi-secrets-store-provider-azure/csi-secrets-store-provider-azure --generate-name --set secrets-store-csi-driver.syncSecret.enabled=true
@iamNoah1
iamNoah1 / create-role-assigments.sh
Last active November 24, 2020 15:35
Create Role Assignments
clientId=`az aks show --name myk8s --resource-group aks2akvrg |jq -r .identityProfile.kubeletidentity.clientId`
nodeResourceGroup=`az aks show --name myk8s --resource-group aks2akvrg |jq -r .nodeResourceGroup`
subId=`az account show | jq -r .id`
az role assignment create --role "Managed Identity Operator" --assignee $clientId --scope /subscriptions/$subId/resourcegroups/aks2akvrg
az role assignment create --role "Managed Identity Operator" --assignee $clientId --scope /subscriptions/$subId/resourcegroups/$nodeResourceGroup
az role assignment create --role "Virtual Machine Contributor" --assignee $clientId --scope /subscriptions/$subId/resourcegroups/$nodeResourceGroup
@iamNoah1
iamNoah1 / create-aad-pod-identity.sh
Last active November 24, 2020 08:21
Create aad pod identity
helm repo add aad-pod-identity https://raw.githubusercontent.com/Azure/aad-pod-identity/master/charts
helm install pod-identity aad-pod-identity/aad-pod-identity
@iamNoah1
iamNoah1 / set-key-vault-permissions.sh
Last active December 13, 2020 13:55
set read permissions for key vault
clientId=`az identity show --name aks2kvIdentity --resource-group aks2akvrg |jq -r .clientId`
principalId=`az identity show --name aks2kvIdentity --resource-group aks2akvrg |jq -r .principalId`
subId=`az account show | jq -r .id`
az role assignment create --role "Reader" --assignee $principalId --scope /subscriptions/$subId/resourceGroups/aks2akvrg/providers/Microsoft.KeyVault/vaults/myk8skv
az keyvault set-policy -n myk8skv --secret-permissions get --spn $clientId
az keyvault set-policy -n myk8skv --key-permissions get --spn $clientId
@iamNoah1
iamNoah1 / identity-binding.yaml
Last active November 24, 2020 14:38
create azure identity binding
apiVersion: aadpodidentity.k8s.io/v1
kind: AzureIdentity
metadata:
name: "aks-kv-identity"
spec:
type: 0
resourceID: /subscriptions/<subscription id>/resourcegroups/aks2akvrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/aks2kvIdentity
clientID: "<clientId>"
---
apiVersion: aadpodidentity.k8s.io/v1
@iamNoah1
iamNoah1 / SecretProviderClass.yaml
Last active November 24, 2020 14:56
secret provider class
apiVersion: secrets-store.csi.x-k8s.io/v1alpha1
kind: SecretProviderClass
metadata:
name: spc-myk8skv
spec:
provider: azure
secretObjects:
- secretName: test-secret
data:
- key: key
@iamNoah1
iamNoah1 / secret-injection.yaml
Last active November 24, 2020 13:49
inject secret
apiVersion: v1
kind: Pod
metadata:
name: inject-secrets-from-akv
labels:
aadpodidbinding: azure-pod-identity-binding-selector
spec:
containers:
- name: nginx
@iamNoah1
iamNoah1 / console-logging-tests.cs
Last active December 17, 2020 14:51
.NetCore Console Logging in Unit Tests
...
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Logging;
public class Tester
{
[Fact]
public void TestSomeClassThatUsesLogging()