-
Notifications
You must be signed in to change notification settings - Fork 0
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
Christopher Becker
committed
Jun 14, 2024
1 parent
6c29eb4
commit fb6c095
Showing
3 changed files
with
78 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: wings-example-app | ||
labels: | ||
app: wings-example-app | ||
namespace: wings-app | ||
spec: | ||
replicas: 3 | ||
selector: | ||
matchLabels: | ||
app: wings-example-app | ||
template: | ||
metadata: | ||
labels: | ||
app: wings-example-app | ||
spec: | ||
containers: | ||
- name: wings-example-app | ||
image: local/wings-example-app:latest | ||
ports: | ||
- containerPort: 5000 | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: wings-example-app | ||
namespace: wings-app | ||
spec: | ||
selector: | ||
app: wings-example-app | ||
ports: | ||
- protocol: TCP | ||
port: 5000 | ||
targetPort: 5000 | ||
type: ClusterIP |
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,35 @@ | ||
#!/bin/bash | ||
|
||
NAMESPACE="wings-app" | ||
SERVICE_NAME="wings-example-app" | ||
LOCAL_PORT=5000 | ||
REMOTE_PORT=5000 | ||
|
||
# Funktion zum Beenden der Port-Forwarding-Verbindung | ||
cleanup() { | ||
echo "Beende Port-Forwarding..." | ||
kill $PORT_FORWARD_PID | ||
wait $PORT_FORWARD_PID 2>/dev/null | ||
echo "Port-Forwarding beendet." | ||
} | ||
|
||
echo "Starte Port-Forwarding von ${LOCAL_PORT} zu ${SERVICE_NAME}:${REMOTE_PORT}..." | ||
kubectl port-forward svc/${SERVICE_NAME} ${LOCAL_PORT}:${REMOTE_PORT} --namespace ${NAMESPACE} & | ||
PORT_FORWARD_PID=$! | ||
|
||
sleep 5 | ||
|
||
if ps -p $PORT_FORWARD_PID > /dev/null | ||
then | ||
echo "Port-Forwarding läuft." | ||
|
||
CURL_RESPONSE=$(curl -s -w "\nHTTP-Status: %{http_code}\n" http://localhost:${LOCAL_PORT}) | ||
|
||
echo "Antwort von curl:" | ||
echo "$CURL_RESPONSE" | ||
|
||
cleanup | ||
else | ||
echo "Port-Forwarding fehlgeschlagen." | ||
exit 1 | ||
fi |