Skip to content

fmaurica/local-k8s-setup

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

A Local Kubernetes Setup With Gitops

This repo aims at holding code and documentation on how to configure a local (Mac OS first) deployment of Kubernetes that follows Gitops principles.

Resources

Installing DNSMasq

Installing DNSMasq and making it your DNS server allows to route addresse in *.k8s.local to 127.0.0.1, i.e. you own computer.

Linux

Hopefully you're already using NetworkManager. In that case, you just need to get dnsmasq and setup NetworkManager to use it

cat <<EOF | sudo tee /etc/NetworkManager/conf.d/dns.conf
[main]
dns=dnsmasq
EOF
cat <<EOF | sudo tee /etc/NetworkManager/dnsmasq.d/local.conf
address=/.local/127.0.0.1
EOF
sudo systemctl restart NetworkManager

Mac

# Install dnsmasq
brew install dnsmasq
# Copy the default configuration file.
cp $(brew list dnsmasq | grep /dnsmasq.conf.example$) /usr/local/etc/dnsmasq.conf
# Copy the daemon configuration file into place.
sudo cp $(brew list dnsmasq | grep /homebrew.mxcl.dnsmasq.plist$) /Library/LaunchDaemons/
# Start Dnsmasq automatically.
sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
echo "address=/dev/127.0.0.1" >> /usr/local/etc/dnsmasq.conf
sudo brew services restart dnsmasq
# Create a client for .dev domain
mkdir -p /etc/resolver
echo > /etc/resolver/local <<EOT
nameserver 127.0.0.1
EOT

ping -c 1 test.k8s.local

Installing mkcert And Generating A Self Signed Trusted Certificate

mkcert is a tool that allows to install a Certificate Authorithy (CA) in your keychain and then provision TLS certificates using that CA. That way, your browser will trust your own self signed certificate locally>

We will create an infra namespace in k8s and deploy that certificate there

mkcert --install
mkcert '*.k8s.local'
kubectl create ns infra
kubectl -n infra create secret tls traefik-tls-cert --key=_wildcard.k8s.local-key.pem --cert=_wildcard.k8s.local.pem
rm -f _wildcard.k8s.local-key.pem _wildcard.k8s.local.pem

Installing ArgoCD

We will use ArgoCD to install everything from now on.

# Create ArgoCD namespace
kubectl create namespace argocd
# Deploy latest stable install
kubectl apply -n argocd -k infra-cd/argocd

Deploy with Gitops

Let's deploy now our first ArgoCD application

kubectl apply -n argocd -f https://raw.githubusercontent.com/pgmillon/local-k8s-setup/main/infra-app.yaml

Expose ArgoCD thru Traefik

kubectl apply -f infra-cd/argocd/argocd-ingress-route.yaml

About

A recipe to configure a local k8s with Gitops

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published