Closed jerzy-wachowiak closed 5 years ago
@jerzy-wachowiak I have tried to reproduce in MacOs but no luck, it worked perfectly. In fact, reading stern
docs I see that says that the pod can be a pod query, so I am not sure if it can be the version of stern
you are using or something like that. I have created a PR https://github.com/redhat-developer-demos/istio-tutorial/pull/169 can you review to see if it works in your case? If it works then I will merge the change.
@lordofthejars [1 ] I use https://github.com/wercker/stern/releases/download/1.10.0/stern_windows_amd64.exe and there is an option "-n" for k8s namespace
λ stern -h
Tail multiple pods and containers from Kubernetes
Usage:
stern pod-query [flags]
Flags:
--all-namespaces If present, tail across all namespaces. A specific namespace is ignored even if specified with --namespace.
--color string Color output. Can be 'always', 'never', or 'auto' (default "auto")
--completion string Outputs stern command-line completion code for the specified shell. Can be 'bash' or 'zsh'
-c, --container string Container name when multiple containers in pod (default ".*")
--container-state string If present, tail containers with status in running, waiting or terminated. Default to running. (default "running")
--context string Kubernetes context to use. Default to current context configured in kubeconfig.
-e, --exclude strings Regex of log lines to exclude
-E, --exclude-container string Exclude a Container name
-h, --help help for stern
--kubeconfig string Path to kubeconfig file to use
-n, --namespace string Kubernetes namespace to use. Default to namespace configured in Kubernetes context
-o, --output string Specify predefined template. Currently support: [default, raw, json] (default "default")
-l, --selector string Selector (label query) to filter on. If present, default to ".*" for the pod-query.
-s, --since duration Return logs newer than a relative duration like 5s, 2m, or 3h. Defaults to 48h.
--tail int The number of lines from the end of the logs to show. Defaults to -1, showing all logs. (default -1)
--template string Template to use for log lines, leave empty to use --output flag
-t, --timestamps Print timestamps
-v, --version Print the version and exit
[2] You can skip in stern the -n option if you before have selected the "tutorial" namespace. You can reproduce it this way
λ oc login -u admin -p a
Login successful.
You have access to the following projects and can switch between them with 'oc project <projectname>':
default
istio-operator
istio-system
kube-dns
kube-proxy
kube-public
kube-system
* myproject
openshift
openshift-apiserver
openshift-controller-manager
openshift-core-operators
openshift-infra
openshift-node
openshift-service-cert-signer
openshift-web-console
tutorial
Using project "myproject".
C:\Tools
λ oc get pods -n tutorial
NAME READY STATUS RESTARTS AGE
customer-1-7bml8 2/2 Running 6 1d
customer-1-build 0/1 Completed 0 1d
preference-v1-1-build 0/1 Completed 0 23h
preference-v1-1-jhldg 2/2 Running 6 23h
recommendation-v1-1-7clfx 2/2 Running 6 23h
recommendation-v1-1-build 0/1 Completed 0 23h
C:\Tools
λ stern customer-1-7bml8 -c customer
C:\Tools
λ stern customer-1-7bml8 -c customer -n tutorial
+ customer-1-7bml8 › customer
customer-1-7bml8 customer Starting the Java application using /opt/run-java/run-java.sh ...
customer-1-7bml8 customer exec java -Xms128m -Xmx256m -Djava.net.preferIPv4Stack=true -javaagent:/opt/jolokia/jolokia.jar=config=/opt/jolokia/etc/jolokia.properties -javaagent:/opt/prometheus/jmx_prometheus_javaagent.jar=9779:/opt/prometheus/prometheus-config.yml -XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:+ExitOnOutOfMemoryError -cp . -jar /deployments/customer.jar
...
If you do this
C:\Tools
λ oc project tutorial
Now using project "tutorial" on server "https://192.168.5.100:8443".
C:\Tools
λ stern customer-1-7bml8 -c customer
+ customer-1-7bml8 › customer
customer-1-7bml8 customer Starting the Java application using /opt/run-java/run-java.sh ...
customer-1-7bml8 customer exec java -Xms128m -Xmx256m -Djava.net.preferIPv4Stack=true -javaagent:/opt/jolokia/jolokia.jar=config=/opt/jolokia/etc/jolokia.properties -javaagent:/opt/prometheus/jmx_prometheus_javaagent.jar=9779:/opt/prometheus/prometheus-config.yml -XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:+ExitOnOutOfMemoryError -cp . -jar /deployments/customer.jar
customer-1-7bml8 customer I> No access restrictor found, access to any MBean is allowed
...
it works as the namespace "tutorial" is set implicit by the command before
Ok, but in my case also it works when I do not specify the pod name, but a pod-query stern customer -c customer
Setup Win 10 / Virtual Box / openshift v3.11.0+6c2b013-59) / minishift v1.26.1+1e20f27
Referce to https://redhat-developer-demos.github.io/istio-tutorial/istio-tutorial/1.0.0/2deploy-microservices.html#deploycustomer
stern customer -c customer
run as admin/adminIssue The command
stern customer -c customer
runs but no logs are streamed downSolution the command should be
stern customer-1-7bml8 -c customer -n tutorial
where customer-1-7bml8 is the pod name selected byoc get pods -n tutorial | grep -E "STATUS|Running"