Using ‘kubectl exec’ command, you can log in to a container.
Step 1: Create a definition file to create a Pod.
employeeServicePod.yml
apiVersion: v1
kind: Pod
metadata:
name: employee-service
labels:
app: employee-service
author: krishna
serviceType: webservice
spec:
containers:
- name: employee-service-container
image: jboss/wildfly
Step 2: Create pod from the definition file.
$kubectl create -f employeeServicePod.yml pod/employee-service created
Wait until Pod is in Running state.
$kubectl get pods
NAME READY STATUS RESTARTS AGE
employee-service 1/1 Running 0 12s
Execute the below command to launch the bash shell of the container.
kubectl exec -it {podName} -c {containerName} -- /bin/bash
Execute below command to open bash shell of employee-service-container.
kubectl exec -it employee-service -c employee-service-container -- /bin/bash
$kubectl exec -it employee-service -c employee-service-container -- /bin/bash [jboss@employee-service ~]$ [jboss@employee-service ~]$ pwd /opt/jboss [jboss@employee-service ~]$ [jboss@employee-service ~]$ ls wildfly [jboss@employee-service ~]$
No comments:
Post a Comment