Skip to content

Commit

Permalink
Add 'kubectl ko trace' command's default namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyanker committed Mar 6, 2021
1 parent 4d32086 commit fad9473
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions dist/images/kubectl-ko
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ tcpdump(){
namespace=$(echo "$namespacedPod" | cut -d "/" -f1)
podName=$(echo "$namespacedPod" | cut -d "/" -f2)
if [ "$podName" = "$namespacedPod" ]; then
nodeName=$(kubectl get pod "$podName" -o jsonpath={.spec.nodeName})
mac=$(kubectl get pod "$podName" -o jsonpath={.metadata.annotations.ovn\\.kubernetes\\.io/mac_address})
hostNetwork=$(kubectl get pod "$podName" -o jsonpath={.spec.hostNetwork})
else
nodeName=$(kubectl get pod "$podName" -n "$namespace" -o jsonpath={.spec.nodeName})
hostNetwork=$(kubectl get pod "$podName" -n "$namespace" -o jsonpath={.spec.hostNetwork})
namespace="default"
fi

nodeName=$(kubectl get pod "$podName" -n "$namespace" -o jsonpath={.spec.nodeName})
hostNetwork=$(kubectl get pod "$podName" -n "$namespace" -o jsonpath={.spec.hostNetwork})

if [ -z "$nodeName" ]; then
echo "Pod $namespacedPod not exists on any node"
exit 1
Expand Down Expand Up @@ -62,8 +60,7 @@ trace(){
namespace=$(echo "$1" | cut -d "/" -f1)
podName=$(echo "$1" | cut -d "/" -f2)
if [ "$podName" = "$1" ]; then
echo "namespace is required"
exit 1
namespace="default"
fi

podIP=$(kubectl get pod "$podName" -n "$namespace" -o jsonpath={.metadata.annotations.ovn\\.kubernetes\\.io/ip_address})
Expand Down
2 changes: 1 addition & 1 deletion pkg/ovnmonitor/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,6 @@ func ParseFlags() (*Configuration, error) {
ServiceNorthdFilePidPath: *argServiceNorthdFilePidPath,
}

klog.Infof("ovn monnitor config is %+v", config)
klog.Infof("ovn monitor config is %+v", config)
return config, nil
}

0 comments on commit fad9473

Please sign in to comment.