Skip to content

Commit 6e41c5a

Browse files
Updated kubectl applogs plugin to remove Namespace parameter
1 parent 6bc0ec9 commit 6e41c5a

File tree

7 files changed

+13
-17
lines changed

7 files changed

+13
-17
lines changed

examples/multitenancy/application-hosting/odoo/steps.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ This example shows delivering Bitnami Odoo Helm chart as-a-service using KubePlu
6969
- this will show all the resources that KubePlus has created for the odoo instance
7070

7171
10. Check logs:
72-
$ kubectl applogs OdooService sample-odooservice default -k kubeplus-saas-provider.json
72+
$ kubectl applogs OdooService sample-odooservice -k kubeplus-saas-provider.json
7373

7474
11. Get application URL:
7575
$ appurl=`kubectl appurl OdooService sample-odooservice default -k kubeplus-saas-provider.json`

examples/multitenancy/application-hosting/wordpress/steps.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ $ kubectl kubeplus commands
7575
- should see all the created Kubernetes objects for this application instance
7676

7777
13. Get logs:
78-
$ kubectl applogs WordpressService wp-tenant1 $KUBEPLUS_NS -k kubeplus-saas-provider.json
78+
$ kubectl applogs WordpressService wp-tenant1 -k kubeplus-saas-provider.json
7979
- should see logs for all the containers in both the Pods
8080

8181
14. Get metrics:

examples/multitenancy/hello-world/saas-and-managed-app-testing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Multi-namespace setup
6161
- hs1 namespace has been created
6262
19. kubectl appurl HelloWorldService hs1 default -k consumer.conf
6363
- curl the IP address received. Should see "Hello hello hello"
64-
20. kubectl applogs HelloWorldService hs1 default -k consumer.conf
64+
20. kubectl applogs HelloWorldService hs1 -k consumer.conf
6565
- Should see app logs
6666
21. kubectl connections HelloWorldService hs1 default -i Namespace:$KUBEPLUS_NS -k consumer.conf
6767
- Should see created resources' listing
@@ -106,7 +106,7 @@ Single namespace setup
106106
- Hello World Pod in kubeplus namespace
107107
18. kubectl appurl HelloWorldService hs1 kubeplus -k provider.conf
108108
- curl the IP address received. Should see "Hello hello hello"
109-
19. kubectl applogs HelloWorldService hs1 kubeplus -k provider.conf
109+
19. kubectl applogs HelloWorldService hs1 -k provider.conf
110110
- Should see app logs
111111
20. kubectl connections HelloWorldService hs1 kubeplus -i Namespace:$KUBEPLUS_NS -k provider.conf
112112
- Should see created resources' listing

examples/multitenancy/hello-world/steps.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ You can use either the provider.conf or consumer.conf in below commands.
8787
- should see "Hello hello hello" displayed
8888

8989
6. Retrievel application logs
90-
- kubectl applogs HelloWorldService hs1 default -k consumer.conf
90+
- kubectl applogs HelloWorldService hs1 -k consumer.conf
9191

9292
7. Retrievel application metrics
9393
- kubectl metrics HelloWorldService hs1 -k consumer.conf

examples/multitenancy/platform-engineering/steps.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Product team
8282
- this will show all the resources that KubePlus has created for the custom mysql instance
8383

8484
6. Check logs:
85-
$ kubectl applogs CustomMysqlService prod-mysql default -k consumer.conf
85+
$ kubectl applogs CustomMysqlService prod-mysql -k consumer.conf
8686

8787
7. Check metrics:
8888
$ kubectl metrics CustomMysqlService prod-mysql -k consumer.conf

plugins/crlogs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ def get_logs(self, pod, namespace, kubeconfig):
4545
crLogs = CRLogs()
4646
kind = sys.argv[1]
4747
instance = sys.argv[2]
48-
namespace = sys.argv[3]
49-
kubeconfig = sys.argv[4]
48+
kubeconfig = sys.argv[3]
5049
resources = {}
5150

5251
pods = crLogs.get_pods_in_ns(kind, instance, kubeconfig)

plugins/kubectl-applogs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,22 @@ print_help () {
77
echo " kubectl applogs"
88
echo ""
99
echo "SYNOPSIS"
10-
echo " kubectl applogs <Kind> <Instance> <Namespace> -k <Absolute path to kubeconfig>"
10+
echo " kubectl applogs <Kind> <Instance> -k <Absolute path to kubeconfig>"
1111
echo ""
1212
echo "DESCRIPTION"
13-
echo " kubectl applogs shows container logs for all the containers of all the Pods that are related to the input Kubernetes resource."
13+
echo " kubectl applogs shows container logs for all the containers of all the Pods that are related to the app instance."
1414
exit 0
1515
}
1616

17-
if (( $# < 5 )); then
17+
if (( $# < 4 )); then
1818
print_help
1919
fi
2020

2121
kind=$1
2222
instance=$2
23-
namespace=$3
2423

2524
kubeconfig1="$HOME/.kube/config" # Default value
2625

27-
shift;
2826
shift;
2927
shift;
3028

@@ -49,19 +47,18 @@ if [ $# = 4 ] && [[ $4 == *"kubeconfig="* ]]; then
4947
kubeconfig=$4
5048
fi
5149

52-
check_namespace $namespace $kubeconfig
53-
5450
canonicalKind=$(get_canonical_kind $kind)
5551

5652
if [[ $canonicalKind == *"Unknown"* ]]; then
5753
echo "$canonicalKind"
5854
exit 0
5955
fi
6056

61-
resStatus=`kubectl $kubeconfig get $kind $instance -n $namespace -o json 2>&1`
57+
kubeplusNamespace=`kubectl get pods -A $kubeconfig | grep kubeplus-deployment | awk '{print $1}'`
58+
resStatus=`kubectl $kubeconfig get $kind $instance -n $kubeplusNamespace -o json 2>&1`
6259
if [[ $resStatus =~ 'Error' ]]; then
6360
echo $resStatus
6461
exit 0
6562
fi
6663

67-
python /$KUBEPLUS_HOME/plugins/crlogs.py $canonicalKind $instance $namespace $kubeconfig
64+
python /$KUBEPLUS_HOME/plugins/crlogs.py $canonicalKind $instance $kubeconfig

0 commit comments

Comments
 (0)