Pods managed by deploy or daemonset don't have a fixed name, you must get the pod name and then get the log for the pods and containers.
Here is a simple script gets all pods in one namespace and get logs for all containers in that pod.
#!/bin/bash
ns=some-namespace
for pname in `kubectl -n $ns get pods | grep Running | awk '{ print $1}'`; do
# pname=$(echo $pname | tr -d '"')
pbody=$(kubectl -n $ns get pods $pname -o json)
csize=$(echo $pbody | jq '.status.containerStatuses | length')
echo "pod $pname has $csize containers"
for i in $( seq 0 $(($csize - 1)) ); do
cname=$(echo $pbody | jq .status.containerStatuses[$i].name | tr -d '"')
echo " get logs for $cname"
kubectl -n $ns logs $pname -c $cname >"$pname-$cname".log
echo " get logs for previous $cname"
kubectl -n $ns logs $pname -c $cname -p >"$pname-$cname-previous".log 2>&1
done
done