Skip to content

Commit

Permalink
Merge pull request #13 from seungkyua/ingress-deploy-temporary
Browse files Browse the repository at this point in the history
Add deploying ingress for temporary
  • Loading branch information
seungkyua authored Oct 1, 2021
2 parents fc20eb2 + 37691d8 commit 1871cfd
Showing 1 changed file with 88 additions and 1 deletion.
89 changes: 88 additions & 1 deletion deploy_apps/tks-service-mesh-wftpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ spec:
value: "{{workflow.parameters.site_name}}"
dependencies:
- grafana-prometheus-resource
- name: deploy-ingress-temporary
template: deploy-ingress-temporary
arguments:
parameters:
- name: site_name
value: "{{workflow.parameters.site_name}}"
- name: kubeconfig_secret_name
value: "{{workflow.parameters.site_name}}-kubeconfig"
dependencies:
- sync-app
- name: copy-eck-secret
arguments: {}
inputs:
Expand Down Expand Up @@ -150,7 +160,7 @@ spec:
kubectl --kubeconfig=/etc/kubeconfig get ns ${TARGET_NAMESPACE}
if [[ $? =~ 1 ]]; then
kubectl --kubeconfig=/etc/kubeconfig create ns ${TARGET_NAMESPACE}
kubectl --kubeconfig=/etc/kubeconfig label ns ${TARGET_NAMESPACE} name=${TARGET_NAMESPACE}
kubectl --kubeconfig=/etc/kubeconfig label ns ${TARGET_NAMESPACE} name=${SOURCE_NAMESPACE}
kubectl --kubeconfig=/etc/kubeconfig label ns ${TARGET_NAMESPACE} taco-tls=enabled
log "INFO" "${TARGET_NAMESPACE} successfully created."
fi
Expand Down Expand Up @@ -208,3 +218,80 @@ spec:
activeDeadlineSeconds: 900
retryStrategy:
limit: 2
- name: deploy-ingress-temporary
inputs:
parameters:
- name: site_name
- name: kubeconfig_secret_name
container:
name: deploy-ingress-temporary
image: 'k8s.gcr.io/hyperkube:v1.18.6'
command:
- /bin/bash
- '-c'
- |
function log() {
level=$1
msg=$2
date=$(date '+%F %H:%M:%S')
echo "[$date] $level $msg"
}
function deploy_ingress() {
ingress_name=$1
namespace=$2
host_name=$3
service_name=$4
service_port=$5
kubectl --kubeconfig=/etc/kubeconfig get ing $ingress_name -n $namespace
if [[ $? =~ 1 ]]; then
cat <<EOF | kubectl --kubeconfig=/etc/kubeconfig apply -f -
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
name: $ingress_name
namespace: $namespace
spec:
rules:
- host: $host_name
http:
paths:
- pathType: ImplementationSpecific
backend:
service:
name: $service_name
port:
number: $service_port
tls:
- hosts:
- $host_name
secretName: taco-cat-tls
EOF
log "INFO" "${ingress_name} in ${namespace} successfully created."
fi
}
GRAFANA_HOST=grafana-$(echo "${SITE_NAME:0:8}").taco-cat.xyz
KIBANA_HOST=kibana-$(echo "${SITE_NAME:0:8}").taco-cat.xyz
KIALI_HOST=kiali-$(echo "${SITE_NAME:0:8}").taco-cat.xyz
cat <<< "$KUBE_CONFIG" > /etc/kubeconfig
deploy_ingress "grafana" "lma" $GRAFANA_HOST "grafana" "80"
deploy_ingress "kibana" "lma" $KIBANA_HOST "eck-kibana-kb-http" "5601"
deploy_ingress "kiali" "istio-system" $KIALI_HOST "kiali" "20001"
env:
- name: SITE_NAME
value: '{{inputs.parameters.site_name}}'
- name: KUBE_CONFIG
valueFrom:
secretKeyRef:
name: "{{ inputs.parameters.kubeconfig_secret_name }}"
key: value
activeDeadlineSeconds: 900
retryStrategy:
limit: 2

0 comments on commit 1871cfd

Please sign in to comment.