I am using Init container in my bitbucket pipeline, my requirement is to print the kubernetes pod logs using kubectl logs -f -c during execution of init container.
Here test and test1 are gradlew commands which will execute... I am looking for a way I can display kubectl logs for any failures in init container and output of command execution automatically in pipeline.
Kindly note I can always verify the logs manually using kubectl logs -f -c but my requirement is to display automatically.
apiVersion: v1
kind: Pod
metadata:
name: test
spec:
containers:
- name: test-ci
image: busybox
command: [ "/bin/sh", "-c", "--" ]
args: [ "while true; do sleep 30; done;" ]
imagePullPolicy: Always
initContainers:
- name: service1
image: busybox
command: [ "/bin/sh", "-c", "$(test)" ]
env:
- name: test
valueFrom:
configMapKeyRef:
name: test
key: test
- name: service2
image: busybox
command: [ "/bin/sh", "-c", "$(test1)" ]
env:
- name: test1
valueFrom:
configMapKeyRef:
name: test1
key: test1
restartPolicy: Never
configmap:
data:
test:
sh gradlew updateSchemas update -PrunList=test -Penv=test
test1:
sh gradlew updateMasterData update -Penv=test -Pprofile=test
Any help is appreciated!!!