-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
19 changed files
with
179 additions
and
332 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
|
||
if [[ $# -eq 0 ]]; then | ||
echo "Usage: k8s-logs <keyword> [namespace]" | ||
exit 1 | ||
fi | ||
|
||
keyword=$1 | ||
namespace=$2 | ||
|
||
if [[ -z $namespace ]]; then | ||
echo "Select namespace:" | ||
namespaces=($(kubectl get namespaces -o name | cut -d/ -f2)) | ||
PS3="Namespace: " | ||
select namespace in "${namespaces[@]}"; do | ||
if [[ -n $namespace ]]; then | ||
break | ||
fi | ||
done | ||
fi | ||
|
||
pod=$(kubectl get pods -n "$namespace" | grep "$keyword" | head -1 | awk '{print $1}') | ||
if [[ -z $pod ]]; then | ||
echo "No pods found for keyword: $keyword" | ||
exit 1 | ||
fi | ||
|
||
containers=($(kubectl get pods "$pod" -n "$namespace" -o jsonpath='{.spec.containers[*].name}')) | ||
if [[ ${#containers[@]} -eq 1 ]]; then | ||
container=${containers[0]} | ||
else | ||
echo "Select container:" | ||
PS3="Container: " | ||
select container in "${containers[@]}"; do | ||
if [[ -n $container ]]; then | ||
break | ||
fi | ||
done | ||
fi | ||
|
||
kubectl logs -f "$pod" -n "$namespace" -c "$container" | ||
|
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,82 @@ | ||
#!/bin/bash | ||
|
||
# function to print usage message | ||
function usage { | ||
echo "Usage: $0 keyword [namespace]" | ||
echo " keyword: a string that identifies the pod you want to access, e.g. amf, smf, upf" | ||
echo " namespace (optional): the Kubernetes namespace where the pod is running" | ||
echo "If no namespace is specified, a namespace picker will be displayed." | ||
} | ||
|
||
# Function to prompt the user to select a namespace from a list | ||
select_namespace() { | ||
echo "Select a namespace:" | ||
select NAMESPACE in $(kubectl get namespaces -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}') | ||
do | ||
if [ -n "$NAMESPACE" ] | ||
then | ||
break | ||
fi | ||
done | ||
} | ||
|
||
# Function to prompt the user to select a container from a list | ||
select_container() { | ||
echo "Select a container:" | ||
select CONTAINER in $(kubectl get pod $POD -n $NAMESPACE -o jsonpath='{range .spec.containers[*]}{.name}{"\n"}{end}') | ||
do | ||
if [ -n "$CONTAINER" ] | ||
then | ||
break | ||
fi | ||
done | ||
} | ||
|
||
# Display help message if no arguments provided | ||
if [ "$#" -eq 0 ] | ||
then | ||
usage | ||
exit 1 | ||
fi | ||
|
||
POD_KEYWORD=$1 | ||
|
||
# Prompt for namespace if not specified | ||
if [ "$#" -eq 1 ] | ||
then | ||
select_namespace | ||
else | ||
NAMESPACE=$2 | ||
fi | ||
|
||
POD=$(kubectl get pods -n $NAMESPACE | grep "$POD_KEYWORD" | awk '{print $1}') | ||
|
||
if [ -z "$POD" ] | ||
then | ||
echo "No pod found with keyword: $POD_KEYWORD in namespace: $NAMESPACE" | ||
exit 1 | ||
fi | ||
|
||
CONTAINER_COUNT=$(kubectl get pod $POD -n $NAMESPACE -o jsonpath='{range .spec.containers[*]}{.name}{"\n"}{end}' | wc -l) | ||
|
||
if [ "$CONTAINER_COUNT" -eq 1 ] | ||
then | ||
CONTAINER=$(kubectl get pod $POD -n $NAMESPACE -o jsonpath='{.spec.containers[0].name}') | ||
else | ||
select_container | ||
fi | ||
|
||
# Try bash shell, fallback to sh | ||
SHELLS=("bash" "sh") | ||
for SHELL in "${SHELLS[@]}" | ||
do | ||
if kubectl exec $POD -n $NAMESPACE -c $CONTAINER -- $SHELL -c 'exit 0' > /dev/null 2>&1 | ||
then | ||
kubectl exec -it $POD -n $NAMESPACE -c $CONTAINER -- $SHELL | ||
exit 0 | ||
fi | ||
done | ||
|
||
echo "No supported shell found in pod: $POD" | ||
exit 1 | ||
|
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,2 @@ | ||
#!/bin/bash | ||
/ueransim/nr-gnb --config /ueransim/config/free5gc-gnb.yaml |
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
resources: | ||
- ue-configmap.yaml | ||
- ue-deployment.yaml | ||
- ue-deployment.yaml | ||
|
||
configMapGenerator: | ||
- name: ue1-configmap | ||
files: | ||
- ue1.yaml | ||
- wrapper.sh |
Oops, something went wrong.