feat: truenas tasks, cleanup

This commit is contained in:
JJGadgets
2023-07-22 02:22:41 +08:00
parent 2aec0df860
commit 5bdc97e74e
6 changed files with 67 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
creation_rules:
- path_regex: (k8s|kube|kubernetes)\/.*tal.*\.sops\.ya?ml
- path_regex: ((.local|pulumi|terraform)\/.*|(k8s|kube|kubernetes)\/.*tal.*)\.sops\.ya?ml
input_type: yaml
pgp: >-
31E70E5BC80C58AFF5DD649921AC5A1AC6E5B7F2

View File

@@ -0,0 +1,32 @@
---
version: "3"
# includes: {}
# k8s:
# internal: true
# taskfile: ../k8s
# cluster:
# internal: true
# taskfile: ../cluster
# vars:
# IP: '{{ or .IP (fail "Missing `IP` environment variable for cluster!") }}'
tasks:
k3s-init:
desc: After initializing k3s in TrueNAS SCALE GUI, run this task to manage k3s outside TrueNAS.
vars:
IP: '{{ or .IP (fail "Missing `IP` environment variable for TrueNAS host IP!") }}'
PORT: '{{ .PORT | default "22" }}'
C: '{{ or .C (fail "Missing `C` environment variable for cluster!") }}'
cmds:
- |
ssh root@{{.IP}} -p {{.PORT}} \
'iptables -D INPUT -p tcp -m tcp --dport 6443 -m comment --comment "iX Custom Rule to drop connection requests to k8s cluster from external sources" -j DROP;
iptables -A INPUT -p tcp -m tcp --dport 6443 -m comment --comment "CUSTOM: Expose k3s kube-apiserver access" -j ACCEPT;
cat /etc/rancher/k3s/k3s.yaml' | yq '.clusters.0.cluster.server = "https://{{.IP}}:6443" | .clusters.0.name = "{{.C}}" | .users.0.name = "{{.C}}" | .contexts.0.name = "{{.C}}" | .contexts.0.context.cluster = "{{.C}}" | .contexts.0.context.user = "{{.C}}" | .current-context = "{{.C}}"' > ~/.kube/k3s-{{.C}}.yaml
- cat ~/.kube/k3s-{{.C}}.yaml; printf "%s " "Press enter to continue"; read ans
- cp ~/.kube/config ~/.kube/config.bak || true
- |
KUBECONFIG="$HOME/.kube/config.bak:$HOME/.kube/k3s-{{.C}}.yaml" kubectl config view --flatten &&
KUBECONFIG="$HOME/.kube/config.bak:$HOME/.kube/k3s-{{.C}}.yaml" kubectl config view --flatten > $HOME/.kube/config

View File

@@ -26,6 +26,10 @@ includes:
rook:
aliases: [r]
taskfile: .taskfiles/rook
truenas:
aliases: [nas]
taskfile: .taskfiles/truenas/Taskfile.dist.yaml
tasks:
default:

View File

@@ -0,0 +1,26 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/cilium.io/ciliumnetworkpolicy_v2.json
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
name: rook-ceph-cluster
namespace: &app rook-ceph
spec:
endpointSelector: {}
ingress:
# same namespace
- fromEndpoints:
- matchLabels:
io.kubernetes.pod.namespace: *app
egress:
# same namespace
- toEndpoints:
- matchLabels:
io.kubernetes.pod.namespace: *app
# hostNet Ceph cluster
- toEntities:
- host
- remote-node
toPorts:
- ports:
- port: "3300"

View File

@@ -18,9 +18,9 @@ spec:
fullnameOverride: *app
automountServiceAccountToken: false
controller:
type: statefulset
# type: deployment
# replicas: 1
# type: statefulset
type: deployment
replicas: 1
image:
repository: docker.io/${APPNAME}/server
tag: latest@sha256:c10a2938d3a8c15169a3ed2f6d08d25430d22cef3d5749d57ab3a9052d60354c

View File

@@ -9,9 +9,4 @@ spec:
dependsOn:
- name: 1-core-storage-rook-ceph-cluster
- name: 1-core-ingress-nginx-app
#- name: 1-core-storage-volsync-app
healthChecks:
- name: ${APPNAME}
namespace: ${APPNAME}
kind: HelmRelease
apiVersion: helm.toolkit.fluxcd.io/v2beta1
#- name: 1-core-storage-volsync-app