Skip to content

Instantly share code, notes, and snippets.

@yelinaung
Created March 12, 2021 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yelinaung/d4de7531540e9f2e021a952be0b36899 to your computer and use it in GitHub Desktop.
Save yelinaung/d4de7531540e9f2e021a952be0b36899 to your computer and use it in GitHub Desktop.
#!/bin/bash
NAME=$1
HOST=$2
PORT=$3
if [ -z "$3" ]; then
echo "$0 [name] [ip] [port]"
exit 1
fi
cat yaml/template.external_endpoints.yml \
| sed "s/ENDPOINTS_NAME/${NAME}/g" \
| sed "s/ENDPOINTS_IP/${HOST}/g" \
| sed "s/ENDPOINTS_PORT/${PORT}/g" \
| kubectl apply -f -
cat yaml/template.external_service.yml \
| sed "s/SERVICE_NAME/${NAME}/g" \
| sed "s/SERVICE_IP/${HOST}/g" \
| sed "s/SERVICE_PORT/${PORT}/g" \
| kubectl apply -f -
kind: Endpoints
apiVersion: v1
metadata:
name: ENDPOINTS_NAME
subsets:
- addresses:
- ip: ENDPOINTS_IP
ports:
- port: ENDPOINTS_PORT
kind: Service
apiVersion: v1
metadata:
name: SERVICE_NAME
spec:
ports:
- protocol: TCP
port: SERVICE_PORT
targetPort: SERVICE_PORT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment