-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
1,989 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
shared/* | ||
.vagrant | ||
|
||
!shared/.do_not_remove | ||
# These are shared configs, need to be checked in to git. | ||
!shared/k3s | ||
!shared/extra.hosts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: cat-gateway-docs | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: docs-nginx | ||
template: | ||
metadata: | ||
labels: | ||
app: docs-nginx | ||
spec: | ||
containers: | ||
- name: docs-nginx | ||
image: localhost/cat-voices-docs:latest | ||
ports: | ||
- containerPort: 80 | ||
name: http | ||
protocol: TCP | ||
resources: | ||
limits: | ||
cpu: "1" | ||
memory: 500Mi | ||
requests: | ||
cpu: "0.1" | ||
memory: 100Mi | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: cat-gateway-docs | ||
spec: | ||
type: LoadBalancer | ||
ports: | ||
- port: 8080 | ||
targetPort: 80 | ||
selector: | ||
app: cat-gateway-docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import socket | ||
import sys | ||
|
||
|
||
def parse_extra_hostnames(hostnames): | ||
""" | ||
This function takes a file of hostnames and returns a list of tuples containing the IP address and hostname for each entry. | ||
The input should be a file with one hostname per line, formatted as "IP_Address Hostname". | ||
The function will ignore any lines that start with "#" and any extra hostnames on the same line. | ||
""" | ||
with open(hostnames) as f: | ||
lines = f.readlines() | ||
lines = [line.strip() for line in lines] | ||
lines = [line for line in lines if line != "" and not line.startswith("#")] | ||
|
||
result = [] | ||
for line in lines: | ||
split = line.split() | ||
result.append((split[0], split[1])) | ||
return result | ||
|
||
|
||
def status(hostname, resolved_ip, ok): | ||
print(f"{hostname:<25} : {resolved_ip:>15} : {ok}") | ||
|
||
|
||
def check_hostname(hostname, ip): | ||
# Check the hostame resolves to the expected IP | ||
ok = "OK" | ||
try: | ||
resolved_ip = socket.gethostbyname(hostname) | ||
if resolved_ip != ip: | ||
ok = f"FAIL. Set `{ip:<15} {hostname:<25}` in /etc/hosts." | ||
except socket.error as e: | ||
resolved_ip = "None" | ||
ok = f"FAIL. Add `{ip:<15} {hostname:<25}` to /etc/hosts" | ||
|
||
status(hostname, resolved_ip, ok) | ||
|
||
return ok == "OK" | ||
|
||
|
||
everything_ok = True | ||
|
||
extra_hosts = parse_extra_hostnames(sys.argv[1]) | ||
|
||
status("HOSTNAME", "RESOLVED IP", "STATUS") | ||
status("-------------------------", "---------------", "------") | ||
|
||
for host in extra_hosts: | ||
everything_ok = check_hostname(host[1], host[0]) and everything_ok | ||
|
||
if not everything_ok: | ||
sys.exit(1) | ||
sys.exit(0) |
Empty file.
Oops, something went wrong.