Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Removing esudo from kubectl functions
Browse files Browse the repository at this point in the history
Fixes: #5593

Signed-off-by: Unmesh Deodhar <[email protected]>
  • Loading branch information
UnmeshDeodhar committed Jul 7, 2023
1 parent 6fcc51c commit 27920f1
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions integration/kubernetes/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ k8s_wait_for_pod_ready_state() {
local pod_name="${1}"
local wait_time="${2:-10}"

esudo kubectl wait --for=condition=ready "pod/${pod_name}" --timeout=${wait_time}s
kubectl wait --for=condition=ready "pod/${pod_name}" --timeout=${wait_time}s
}

# Wait until the pod is 'Deleted'. Fail if it hits the timeout.
k8s_wait_for_pod_delete_state() {
local pod_name="${1}"
local wait_time="${2:-10}"

esudo kubectl wait --for=delete "pod/${pod_name}" --timeout=${wait_time}s
kubectl wait --for=delete "pod/${pod_name}" --timeout=${wait_time}s
}

# Find container id
k8s_get_container_id() {
local pod_name="${1}"

# Get container id from pod info
local container_id=$(esudo kubectl get pod "${pod_name}" \
local container_id=$(kubectl get pod "${pod_name}" \
-o jsonpath='{.status.containerStatuses..containerID}' \
| sed "s|containerd://||g")

Expand All @@ -68,10 +68,10 @@ k8s_delete_by_yaml() {
local yaml="${2}"

# Retrieve pod name
local pod_name=$(esudo kubectl get pod -o wide | grep ${partial_pod_name} | awk '{print $1;}' || true)
local pod_name=$(kubectl get pod -o wide | grep ${partial_pod_name} | awk '{print $1;}' || true)

# Delete by yaml
esudo kubectl delete -f "${yaml}" 2>/dev/null || true
kubectl delete -f "${yaml}" 2>/dev/null || true

# Verify pod deleted
[ -z "${pod_name}" ] || (k8s_wait_for_pod_delete_state "${pod_name}" || true)
Expand All @@ -83,15 +83,15 @@ k8s_print_info() {
local partial_pod_name="${1}"

echo "-------------------------------------------------------------------------------"
esudo kubectl get nodes -o wide
kubectl get nodes -o wide
echo "-------------------------------------------------------------------------------"
esudo kubectl get services -o wide
kubectl get services -o wide
echo "-------------------------------------------------------------------------------"
esudo kubectl get deployments -o wide
kubectl get deployments -o wide
echo "-------------------------------------------------------------------------------"
esudo kubectl get pods -o wide
kubectl get pods -o wide
echo "-------------------------------------------------------------------------------"
local pod_name=$(esudo kubectl get pod -o wide | grep "${partial_pod_name}" | awk '{print $1;}')
esudo kubectl describe pod "${pod_name}"
local pod_name=$(kubectl get pod -o wide | grep "${partial_pod_name}" | awk '{print $1;}')
kubectl describe pod "${pod_name}"
echo "-------------------------------------------------------------------------------"
}

0 comments on commit 27920f1

Please sign in to comment.