Compare commits
3 Commits
e9e7ae17f0
...
c6dd7c36e1
| Author | SHA1 | Date |
|---|---|---|
|
|
c6dd7c36e1 | |
|
|
0d238ed8a0 | |
|
|
b71e9ae9b2 |
|
|
@ -16,7 +16,7 @@ RUN useradd -m -u 1000 -U -p '' -s /bin/bash hugo \
|
|||
&& mkdir -p /opt/workdir \
|
||||
&& chown -R 1000:1000 /home/hugo /opt/workdir /usr/local/bin/hugo
|
||||
|
||||
USER hugo
|
||||
USER 1000
|
||||
|
||||
WORKDIR /opt/workdir
|
||||
|
||||
|
|
|
|||
|
|
@ -2,103 +2,33 @@
|
|||
title: "{{ replace .Name "-" " " | title }}"
|
||||
date: {{ .Date }}
|
||||
draft: true
|
||||
tags: []
|
||||
---
|
||||
Headers
|
||||
|
||||
# Header 1
|
||||
## Header 2
|
||||
### Header 3
|
||||
#### Header 4 ####
|
||||
##### Header 5 #####
|
||||
###### Header 6 ######
|
||||
# Default post template
|
||||
|
||||
*Emphasize* _emphasize_
|
||||
**Strong** __Strong__
|
||||
A [link](http://example.com "Title").
|
||||
Some text with [a link][1] and another [link][2].
|
||||
## Writing tips
|
||||
1. Find a good topic and commit to it
|
||||
eg how to get started blogging
|
||||
|
||||
[1]: http://example.com/ "Title"
|
||||
[2]: http://example.org/ "Title"
|
||||
2. Make your goals and audience specific
|
||||
Who is my Audience: eg People who want to start blogging, especially about technical topics, but haven’t done it yet.
|
||||
What is my Goal: eg. Give people a concrete set of steps and pointers so they can get started.
|
||||
|
||||
Logo: 
|
||||
Smaller logo: ![Alt][1]
|
||||
[1]: /wp-smaller.png "Title"
|
||||
3. Have a beginning, middle, and end
|
||||
|
||||
Linked logo: [] (http://wordpress.com/ "Title")
|
||||
4. Get feedback and iterate
|
||||
|
||||
Lists
|
||||
5. Add finishing touches: packaging, publication, and promotion
|
||||
|
||||
1. Item
|
||||
2. Item
|
||||
* Mixed
|
||||
* Mixed
|
||||
- or dash
|
||||
3. Item
|
||||
From [freeCodeCamp: How to write a great technical blog post][1]
|
||||
|
||||
Blockquotes
|
||||
|
||||
> Quoted text.
|
||||
> > Quoted quote.
|
||||
|
||||
> * Quoted
|
||||
> * List
|
||||
[1]: https://www.freecodecamp.org/news/how-to-write-a-great-technical-blog-post-414c414b67f6/
|
||||
|
||||
|
||||
Quoted text.
|
||||
## Syntax highlighting example
|
||||
|
||||
Quoted quote.
|
||||
|
||||
Quoted
|
||||
List
|
||||
|
||||
Preformatted
|
||||
|
||||
Begin each line with
|
||||
two spaces or more to
|
||||
make text look
|
||||
e x a c t l y
|
||||
like you type i
|
||||
t.
|
||||
|
||||
|
||||
Begin each line with
|
||||
two spaces or more to
|
||||
make text look
|
||||
e x a c t l y
|
||||
like you type i
|
||||
t.
|
||||
|
||||
Code
|
||||
|
||||
`This is code`
|
||||
|
||||
This is code
|
||||
Code block
|
||||
|
||||
~~~~
|
||||
This is a
|
||||
piece of code
|
||||
in a block
|
||||
~~~~
|
||||
|
||||
```
|
||||
This too
|
||||
```
|
||||
|
||||
Syntax highlighting
|
||||
|
||||
```css
|
||||
#button {
|
||||
border: none;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
Example code
|
||||
|
||||
```go
|
||||
{{<highlight go "linenos=table,hl_lines=8 15-17,linenostart=199">}}
|
||||
```go {linenos=table,hl_lines=8 15-17,linenostart=199}
|
||||
// GetTitleFunc returns a func that can be used to transform a string to
|
||||
// title case.
|
||||
//
|
||||
|
|
@ -121,5 +51,4 @@ func GetTitleFunc(style string) func(s string) string {
|
|||
return tc.Title
|
||||
}
|
||||
}
|
||||
{{</highlight>}}
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
@import "nav";
|
||||
@import "list";
|
||||
@import "syntax";
|
||||
|
||||
html,
|
||||
body {
|
||||
|
|
@ -23,7 +24,7 @@ p {
|
|||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
display: grid;
|
||||
grid-template-columns: 5fr 1.5fr;
|
||||
grid-template-columns: 3fr 1fr;
|
||||
}
|
||||
|
||||
#header {
|
||||
|
|
@ -48,3 +49,16 @@ p {
|
|||
grid-column-end: 3;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.highlight {
|
||||
line-height: 1.5em;
|
||||
margin: 15px 0;
|
||||
|
||||
.chroma {
|
||||
padding-right: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
#openring {
|
||||
margin: 35px 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ nav {
|
|||
}
|
||||
|
||||
.title {
|
||||
font-size: 0.8rem;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
}
|
||||
|
||||
#license {
|
||||
font-size: 0.8rem;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
|
|
|||
23
config.toml
23
config.toml
|
|
@ -29,17 +29,30 @@ summaryLength = 32
|
|||
url = "https://git.vdhsn.com/adam/blog"
|
||||
|
||||
[[menu.other]]
|
||||
name = "keybase.io/aveldhousen"
|
||||
url = "https://keybase.io/aveldhousen"
|
||||
|
||||
[[menu.other]]
|
||||
Title = "Find me on GitHub"
|
||||
name = "github.com/adamveld12"
|
||||
url = "https://github.com/adamveld12"
|
||||
|
||||
[[menu.other]]
|
||||
Title = "Follow me on Keybase"
|
||||
name = "keybase.io/aveldhousen"
|
||||
url = "https://keybase.io/aveldhousen"
|
||||
|
||||
[[menu.other]]
|
||||
name = "RSS"
|
||||
url = "/index.xml"
|
||||
|
||||
[[menu.other]]
|
||||
name = "Resume"
|
||||
url = "/resume_2019.pdf"
|
||||
url = "/resume_2019.pdf"
|
||||
|
||||
[markup]
|
||||
[markup.highlight]
|
||||
codeFences = true
|
||||
guessSyntax = false
|
||||
lineNoStart = 1
|
||||
lineNos = true
|
||||
lineNumbersInTable = true
|
||||
noClasses = false
|
||||
style = "monokai"
|
||||
tabWidth = 4
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
---
|
||||
title: "Kubernetes Loadbalancing with Metal LB"
|
||||
date: 2020-01-02T20:57:36Z
|
||||
tags: ["kubernetes", "homelab", "networking", "bare metal"]
|
||||
draft: false
|
||||
---
|
||||
|
||||
If you run Kubernetes on an IaaS provider like AWS or GCE and create a service with the *LoadBalancer* type, there is glue code included in kubernetes itself that will provision an ELB/ALB for you automatically. When you're running k8s on prem or at home any service you create with the *LoadBalancer* service type will hang indefinitely since there is no way to provision external IPs on your router out of the box. This is where Metal LB comes in.
|
||||
|
||||
[Metal LB][metallb] is a project that implements load balancing for on premises based Kubernetes clusters by responding to ARP requests directly on your network with the MAC address of the worker nodes. This means no setup is required in most cases and you get a nice internal IP that you can port forward on your router. In this post I will walk you through high level set up so you can get traffic from the internet hitting your service in a scalable way.
|
||||
|
||||
## Setup Metal LB
|
||||
|
||||
Installation is easy but you have to make sure you're using a compatible networking add on. I would recommend [Flannel][flannel] or [Kube Router][kube-router] but there are many others supported (some with caveats) that you can learn about in their [compatibility table][metallbcompattable].
|
||||
|
||||
Next you can install Metal LB on your cluster like so:
|
||||
|
||||
```bash
|
||||
kubectl apply -f https://raw.githubusercontent.com/google/metallb/v0.8.3/manifests/metallb.yaml
|
||||
```
|
||||
|
||||
Then set up a config map with an IP address pool. This IP address pool should be in the subnet that is set up on your router or traffic will be dropped. This means that if your router is set up to give out IPs in the range of `192.168.0.2-192.168.0.254` then you should make sure the pool is in that range.
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
namespace: metallb-system
|
||||
name: config
|
||||
data:
|
||||
config: |
|
||||
address-pools:
|
||||
- name: default
|
||||
protocol: layer2
|
||||
addresses:
|
||||
- 192.168.0.240-192.168.0.250
|
||||
```
|
||||
|
||||
Now lets run a pod and service to see this in action. Apply the following with *kubectl*:
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: whoami
|
||||
spec:
|
||||
ports:
|
||||
- protocol: TCP
|
||||
name: web
|
||||
port: 80
|
||||
selector:
|
||||
app: whoami
|
||||
type: LoadBalancer
|
||||
---
|
||||
kind: Deployment
|
||||
apiVersion: apps/v1
|
||||
metadata:
|
||||
namespace: default
|
||||
name: whoami
|
||||
labels:
|
||||
app: whoami
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: whoami
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: whoami
|
||||
spec:
|
||||
containers:
|
||||
- name: whoami
|
||||
image: containous/whoami
|
||||
ports:
|
||||
- name: web
|
||||
containerPort: 80
|
||||
```
|
||||
|
||||
Finally get the external IP address by doing `kubectl get svc whoami`. Visit that IP on port 80 and you should see some output.
|
||||
|
||||
And that's all there is to it. From here you should be able to port forward 80 to that IP and access the service from the internet with the IP given to you by your ISP.
|
||||
|
||||
Next I will show how to set up [Traefik][traefik], a popular and powerful loadbalancer. We'll be able to port forward to traefik and route to multiple services in any way we want.
|
||||
|
||||
|
||||
[metallb]: https://metallb.universe.tf/
|
||||
[metallbcompattable]: https://metallb.universe.tf/installation/network-addons/
|
||||
[flannel]: https://github.com/coreos/flannel/blob/master/Documentation/kubernetes.md
|
||||
[cillium]: https://github.com/cilium/cilium
|
||||
[traefik]: https://docs.traefik.io/v2.0/
|
||||
|
|
@ -1,14 +1,13 @@
|
|||
---
|
||||
title: "Git Tips - Lint + Test Pre-commit Hook"
|
||||
date: 2020-01-01T21:00:39Z
|
||||
tags: [git, bash, ]
|
||||
tags: [git, bash]
|
||||
---
|
||||
|
||||
One of my favorite inventions is a `pre-commit` hook that auto runs test and lint commands from a `makefile` or
|
||||
`package.json` if they're found:
|
||||
|
||||
```sh
|
||||
{{<highlight bash "linenos=table">}}
|
||||
```bash {linenos=table}
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ -f "$PWD/makefile" ] && [ ! -z "$(cat $PWD/makefile | grep '^lint:')" ]; then
|
||||
|
|
@ -26,7 +25,6 @@ elif [ -f "$PWD/package.json" ] && [ ! -z "$(cat $PWD/package.json | grep "^\"te
|
|||
echo "running npm run test"
|
||||
npm run test
|
||||
fi
|
||||
{{</highlight>}}
|
||||
```
|
||||
|
||||
The `/usr/bin/env bash` piece ensures that the script has access to all of the environment variables you expect in your
|
||||
|
|
|
|||
|
|
@ -0,0 +1,91 @@
|
|||
---
|
||||
title: "Kubernetes Loadbalancing with Metal LB"
|
||||
date: 2020-01-02T20:57:36Z
|
||||
tags: ["kubernetes", "homelab", "networking"]
|
||||
draft: false
|
||||
---
|
||||
|
||||
If you run Kubernetes on an IaaS provider like AWS or GCE and create a service with the *LoadBalancer* type, there is glue code included in kubernetes itself that will provision an ELB/ALB for you automatically. When you're running k8s on prem or at home any service you create with the *LoadBalancer* service type will hang indefinitely since there is no way to provision external IPs on your router out of the box. This is where Metal LB comes in.
|
||||
|
||||
[Metal LB][metallb] is a project that implements load balancing for on premises based Kubernetes clusters by responding to ARP requests directly on your network with the MAC address of the worker nodes. This means no setup is required in most cases and you get a nice internal IP that you can port forward on your router. In this post I will walk you through high level set up so you can get traffic from the internet hitting your service in a scalable way.
|
||||
|
||||
## Setup Metal LB
|
||||
|
||||
Installation is easy but you have to make sure you're using a compatible networking add on. I would recommend [Flannel][flannel] or [Kube Router][kube-router] but there are many others supported with caveats that you can [look in their compatibility table][metallbcompattable].
|
||||
|
||||
Next you can install Metal LB on your cluster like so:
|
||||
|
||||
```bash
|
||||
kubectl apply -f https://raw.githubusercontent.com/google/metallb/v0.8.3/manifests/metallb.yaml
|
||||
```
|
||||
|
||||
Then set up a config map with an IP address pool. This IP address pool should be in the subnet that is set up on your router or traffic will be dropped. This means that if your router is set up to give out IPs in the range of `192.168.0.2-192.168.0.254` then you should make sure the pool is in that range.
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
namespace: metallb-system
|
||||
name: config
|
||||
data:
|
||||
config: |
|
||||
address-pools:
|
||||
- name: default
|
||||
protocol: layer2
|
||||
addresses:
|
||||
- 192.168.0.240-192.168.0.250
|
||||
```
|
||||
|
||||
Now lets run a pod and service to see this in action. Apply the following with *kubectl*:
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: whoami
|
||||
spec:
|
||||
ports:
|
||||
- protocol: TCP
|
||||
name: web
|
||||
port: 80
|
||||
selector:
|
||||
app: whoami
|
||||
type: LoadBalancer
|
||||
---
|
||||
kind: Deployment
|
||||
apiVersion: apps/v1
|
||||
metadata:
|
||||
namespace: default
|
||||
name: whoami
|
||||
labels:
|
||||
app: whoami
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: whoami
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: whoami
|
||||
spec:
|
||||
containers:
|
||||
- name: whoami
|
||||
image: containous/whoami
|
||||
ports:
|
||||
- name: web
|
||||
containerPort: 80
|
||||
```
|
||||
|
||||
Finally get the external IP address by doing `kubectl get svc whoami`. Visit that IP on port 80 and you should see some output.
|
||||
|
||||
And that's all there is to it. From here you should be able to port forward 80 to that IP and access the service from the internet with the IP given to you by your ISP.
|
||||
|
||||
Next I will show how to set up [Traefik][traefik], a popular and powerful loadbalancer. We'll be able to port forward to traefik and route to multiple services in any way we want.
|
||||
|
||||
|
||||
[metallb]: https://metallb.universe.tf/
|
||||
[metallbcompattable]: https://metallb.universe.tf/installation/network-addons/
|
||||
[flannel]: https://github.com/coreos/flannel/blob/master/Documentation/kubernetes.md
|
||||
[cillium]: https://github.com/cilium/cilium
|
||||
[traefik]: https://docs.traefik.io/v2.0/
|
||||
Loading…
Reference in New Issue