Skip to content

Instantly share code, notes, and snippets.

View LoPan455's full-sized avatar

Thomas Johander LoPan455

  • Minneapolis, MN
View GitHub Profile
@LoPan455
LoPan455 / unifi_ubuntu_2004.sh
Created February 12, 2023 13:25 — forked from davecoutts/unifi_ubuntu_2004.sh
Install Ubiquiti Unifi Controller on Ubuntu 20.04
# Install Ubiquiti Unifi Controller on Ubuntu 20.04.
# As tested on a fresh install of ubuntu-20.04.1-live-server, August 22nd 2020.
# Thanks to https://gist.github.com/tmuncks for posting the updated install steps.
sudo apt update
sudo apt install --yes apt-transport-https
echo 'deb https://www.ui.com/downloads/unifi/debian stable ubiquiti' | sudo tee /etc/apt/sources.list.d/100-ubnt-unifi.list
sudo wget -O /etc/apt/trusted.gpg.d/unifi-repo.gpg https://dl.ui.com/unifi/unifi-repo.gpg
@LoPan455
LoPan455 / cloud-init.yaml
Created January 16, 2023 22:23
Cloud Init to Provision Postgres 13
#cloud-config
package_update: true
package_upgrade: true
runcmd:
- if [[ $(lsb_release -rs) == "20.04" ]]; then
echo "Ubuntu 20.04 LTS detected. Installing Postgres 13...";
apt-get update;
apt-get install -y postgresql-13 postgresql-client-13;
@LoPan455
LoPan455 / ssh-keys-everywhere.md
Last active December 16, 2022 14:51
Copy A Different User's Public SSH Key to a Remote Server

If a remote server has password access disabled and relies on authorized SSH keys to manage user access, things can get tricky.

The scenario this gist will solve is:

  1. Server A (10.0.1.20) has a user account, ubuntu, that we need to be able to use to login to it from a variety of hosts.
  2. User A has access to a Server A (10.0.1.20) via SSH. Therfore User A's public key is present in Server A's 'authorized_keys' file.
  3. User A's private key is present on a Bastion host that allows password logins.
  4. User B needs to access Server A, and therefore needs her public key copied to Server A. Server A doesn't allow password logins, so we're stuck.
docker stop $(docker ps -aq)
docker system prune -f
docker volume rm $(docker volume ls -q)
docker image rm $(docker image ls -q)
rm -rf /etc/ceph \
/etc/cni \
/etc/kubernetes \
/opt/cni \
/opt/rke \
/run/secrets/kubernetes.io \
@LoPan455
LoPan455 / notes.md
Last active March 16, 2022 12:57
K8s Study Notes

Pods

`https://kubernetes.io/docs/concepts/workloads/pods/ Pods are the smallest deployable units of computing that you can create and manage in Kubernetes.

A Pod (as in a pod of whales or pea pod) is a group of one or more containers, with shared storage and network resources, and a specification for how to run the containers. A Pod's contents are always co-located and co-scheduled, and run in a shared context. A Pod models an application-specific "logical host": it contains one or more application containers which are relatively tightly coupled. In non-cloud contexts, applications executed on the same physical or virtual machine are analogous to cloud applications executed on the same logical host.

A pod might be analagous to a single VM that runs multiple services.

As well as application containers, a Pod can contain init containers that run during Pod startup. You can also inject ephemeral containers for debugging if your cluster offers this.

@LoPan455
LoPan455 / proxmox.md
Created March 1, 2022 04:56
Some ProxMox Cloud init things to remember

There is a file, /etc/cloud/cloud-init.d/99-installer.cfg that holds the defualt, "no sourece" user data. That will be used if you don't add the line below it that looks like: datasource=[NoCloud], or you edit the "no source" user-data to hold the stuff you want.

  • Make sure you turn on the "QEMU Geust Agent" in either the UI or set on the VM via the CLI

You can create VMs from the command line like:

sudo qm clone 9990 404 --name ci-test-8
sudo qm set 404 --cicustom "user=snippets:snippets/user-data.yaml" --ipconfig0 "ip=dhcp" --agent enabled=1
@LoPan455
LoPan455 / explain.md
Created February 16, 2022 14:41 — forked from aw/explain.md
[SOLVED] Proxmox VE and cloud-init snippets etc

Proxmox VE 6.x release includes a feature to add custom cloud-init configs. Unfortunately there is poor documentation, so I had to figure this out by adding pieces of information together.

The custom cloud-init files (user-data, meta-data, network-config)

The cloud-init files need to be stored in a snippet. This is not very well documented:

  1. Go to Storage View -> Storage -> Add -> Directory
  2. Give it an ID such as snippets, and specify any path on your host such as /snippets
  3. Under Content choose Snippets and de-select Disk image (optional)
  4. Upload (scp/rsync/whatever) your user-data, meta-data, network-config files to your proxmox server in /snippets/snippets/ (the directory should be there if you followed steps 1-3)
@LoPan455
LoPan455 / gist:e1eabb938e492c2687ca6d89d1cca888
Created December 14, 2021 13:21
Run an AFP-based Timemachine Docker Container
docker run -d --restart=always \
--net=host \
--name timemachine \
-e CUSTOM_AFP_CONF="false" \
-e CUSTOM_USER="false" \
-e LOG_LEVEL="info" \
-e MIMIC_MODEL="TimeCapsule6,106" \
-e TM_USERNAME="timemachine" \
-e TM_GROUPNAME="timemachine" \
-e TM_UID="1000" \
@LoPan455
LoPan455 / deploy-hugo-to-s3.sh
Created September 4, 2021 15:32
Codeship Script to Push a Hugo Site to S3
#!/bin/bash
# Deploy to AWS S3, http://aws.amazon.com/s3/
#
# Add the following environment variables to your project configuration.
# * AWS_ACCESS_KEY_ID
# * AWS_SECRET_ACCESS_KEY
# * AWS_DEFAULT_REGION
# * AWS_S3_BUCKET
#
# Include in your builds via
@LoPan455
LoPan455 / parameterized-type-ref.md
Created September 4, 2021 15:17
When you can't use a ParameterizedTypeReference for a Generic Class With Type Information

In the example below, I can't use a ParameterizedTypeReference because the compiler erases type information (maybe some additional research on that would be helpful) So you can't do ParameterizedTypeReference<List<Post>>().

In order to get around that, you have to hack this private function together:

fun getPosts(): Mono<PostList> =
        apiClient
            .get()
 .uri { builder -&gt; builder.path("/posts").build() }