Skip to content

Instantly share code, notes, and snippets.

View yankcrime's full-sized avatar
🤠
┬──┬◡ノ(° -°ノ)

Nick Jones yankcrime

🤠
┬──┬◡ノ(° -°ノ)
View GitHub Profile
@yankcrime
yankcrime / azure.md
Last active July 1, 2021 08:55
Azure CLI

Azure CLI foo

List available locations:

az account list-locations | grep uk

List VM images from Canonical:

Kubernetes and External Authentication with Rancher

Users added in Rancher get an object of kind User.

For them to be able to do anything, they need to login to Rancher and authenticate via the external AuthN provider. An instance of kind Token is then created which contains the User Principal account details:

$ kubectl describe user u-smckoeh6vq
Name:          u-smckoeh6vq
Namespace:
@yankcrime
yankcrime / main.tf
Created June 8, 2021 15:39
Rancher Server via Terraform with private CA and custom client certs
resource "kubernetes_secret" "tls_ca" {
metadata {
name = "tls-ca"
namespace = "cattle-system"
}
data = {
"cacerts.pem" = file("./cacerts.pem")
}
depends_on = [
@yankcrime
yankcrime / configuration.nix
Created May 4, 2021 21:04
NixOS configuration for OpenStack
{ config, lib, pkgs, modulesPath, ... }:
{
boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
boot.loader.grub.enable = true;
boot.loader.grub.version = 2;
boot.loader.grub.efiSupport = false;
@yankcrime
yankcrime / preseed.cfg
Created April 20, 2021 11:24
Packer configuration for Ubuntu 20.04 on vSphere with cloud-init and guestinfo
d-i passwd/user-fullname string packerbuilt
d-i passwd/username string packerbuilt
d-i passwd/user-password password PackerBuilt!
d-i passwd/user-password-again password PackerBuilt!
d-i user-setup/allow-password-weak boolean true
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string regular
d-i partman-basicfilesystems/no_swap boolean false
d-i partman-swapfile/size string 0
@yankcrime
yankcrime / main.tf
Created April 16, 2021 07:35
Provisioning a 'RKE' downstream cluster on existing nodes via Terraform
resource "rancher2_cluster" "downstream_cluster" {
name = var.cluster_name
description = var.cluster_description
rke_config {
kubernetes_version = var.kubernetes_version
services {
kube_api {
secrets_encryption_config {
enabled = true
@yankcrime
yankcrime / rke-cleanup.sh
Created April 16, 2021 07:28
Cleanup an RKE node
#!/usr/bin/env bash
docker stop $(docker ps -qa)
docker rm -f $(docker ps -qa)
docker volume rm $(docker volume ls -q)
for mount in $(mount | grep tmpfs | grep '/var/lib/kubelet' | awk '{ print $3 }') /var/lib/kubelet /var/lib/rancher; do umount $mount; done
rm -rf /etc/cni \
/etc/kubernetes \
/opt/cni \
@yankcrime
yankcrime / k3s-aws-cloud-provider.md
Last active January 4, 2025 20:02
Auto-deploying the external AWS Cloud Provider when bootstrapping K3s

Installing K3s with the external ("out-of-tree") AWS Cloud Provider

Pre-requisites

Refer to the upstream project's official documentation for the various pre-requisites. You must have an IAM role with the right permissions attached to your K3s instances, and you must also tag your nodes with a clusterid. Refer to the Rancher documentation for how to do this

Install K3s with the following options:

curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="server \
@yankcrime
yankcrime / rancher2_ad_auth.tf
Last active April 19, 2021 07:25
Terraform Rancher2 provider AD integration example
resource "rancher2_auth_config_activedirectory" "activedirectory" {
servers = var.ad_server
tls = false
port = 389
service_account_username = var.ad_username
service_account_password = var.ad_password
test_username = var.ad_username
test_password = var.ad_password
default_login_domain = var.ad_default_login_domain
user_search_base = var.ad_user_search_base
@yankcrime
yankcrime / terraform.md
Last active July 13, 2022 13:59
Terraform for Kubernetes and Rancher on existing nodes

Terraform example for deploying Kubernetes and Rancher on existing infrastructure

main.tf

resource "rke_cluster" "rancher" {
  ssh_agent_auth        = true
  ignore_docker_version = true
  kubernetes_version    = var.kubernetes_version

  dynamic "nodes" {