Various changes

- Updated logger API.
- Fixed file sourcing.
- Fixed argocd ingress and ACME cert.
This commit is contained in:
Victor Timofei 2021-12-29 15:27:14 +02:00
parent b62464fa42
commit 5e7d850520
Signed by: vtimofei
GPG Key ID: B790DCEBE281403A
7 changed files with 69 additions and 13 deletions

View File

@ -0,0 +1,12 @@
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: argocd-app
namespace: argocd
spec:
dnsNames:
- argocd.DOMAIN
secretName: argocd-app-tls
issuerRef:
name: letsencrypt-cluster-issuer
kind: ClusterIssuer

View File

@ -0,0 +1,27 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: argocd-server-ingress
namespace: argocd
annotations:
cert-manager.io/cluster-issuer: letsencrypt-cluster-issuer
kubernetes.io/ingress.class: nginx
kubernetes.io/tls-acme: "true"
nginx.ingress.kubernetes.io/ssl-passthrough: "true"
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
spec:
rules:
- host: argocd.DOMAIN
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: argocd-server
port:
name: https
tls:
- hosts:
- argocd.DOMAIN
secretName: argocd-app-tls

View File

@ -1,13 +1,13 @@
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-prod
name: letsencrypt-cluster-issuer
spec:
acme:
email: EMAIL_ADDRESS
server: https://acme-v02.api.letsencrypt.org/directory
server: https://acme-staging-v02.api.letsencrypt.org/directory
privateKeySecretRef:
name: letsencrypt-prod-private-key
name: letsencrypt-cluster-issuer-key
solvers:
- http01:
ingress:

9
env
View File

@ -1,14 +1,19 @@
PATH=${PWD}/bin/:$PATH
DOMAIN="${DOMAIN:-example.org}"
EMAIL_ADDRESS="${EMAIL_ADDRESS:-kubernetesadmin@example.org}"
PATH=${PWD}/bin/:$PATH
KUBECTL_BIN="${KUBECTL_BIN:-kubectl}"
INSTALL_DIR="${INSTALL_DIR:-$(pwd)/bin}"
HELM_BIN="${INSTALL_DIR}/helm"
ARGOCD_BIN="${INSTALL_DIR}/argocd"
CERT_MANAGER_VERSION="1.6.1"
export PATH \
EMAIL_ADDRESS \
DOMAIN \
KUBECTL_BIN \
INSTALL_DIR \
HELM_BIN \
ARGOCD_BIN
ARGOCD_BIN \
CERT_MANAGER_VERSION

View File

@ -1,7 +1,7 @@
#!/usr/bin/bash
source env
source logger.sh
source ./env
source ./logger.sh
function install_cert_manager {
${KUBECTL_BIN} create namespace cert-manager
@ -9,16 +9,28 @@ function install_cert_manager {
${HELM_BIN} repo update
${HELM_BIN} install cert-manager jetstack/cert-manager \
--namespace cert-manager \
--version v1.6.1 \
--version "v${CERT_MANAGER_VERSION}" \
--set installCRDs=true
${KUBECTL_BIN} apply \
-f "https://github.com/jetstack/cert-manager/releases/download/v${CERT_MANAGER_VERSION}/cert-manager.crds.yaml"
}
function create_cluster_issuer {
sed "s/EMAIL_ADDRESS/${EMAIL_ADDRESS}/" cluster_issuer.yaml | ${KUBECTL_BIN} apply -f -
sed "s/EMAIL_ADDRESS/${EMAIL_ADDRESS}/g" ./cert-manager/cluster_issuer.yaml | ${KUBECTL_BIN} apply -f -
}
function create_certificates {
sed "s/DOMAIN/${DOMAIN}/g" ./cert-manager/argocd_cert.yaml | ${KUBECTL_BIN} apply -f -
}
function create_argocd_ingress {
sed "s/DOMAIN/${DOMAIN}/g" ./cert-manager/argocd_ingress.yaml | ${KUBECTL_BIN} apply -f -
}
log_info "Installing cert manager..."
install_cert_manager
create_cluster_issuer
create_certificates
create_argocd_ingress
log_info "Installation completed successfuly!"
log_info "Cert-manager installation completed successfuly!"

View File

@ -1,7 +1,7 @@
#!/usr/bin/bash
source env
source logger.sh
source ./env
source ./logger.sh
function install_helm {
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 \

View File

@ -2,5 +2,5 @@ blue_color="\e[34m"
reset_color="\e[0m"
function log_info {
printf "%b%s%b\n" "${blue_color}" "${1}" "${reset_color}"
printf "%b%s%b%s\n" "${blue_color}" "INFO: " "${reset_color}" "${1}"
}