Skip to content

Commit 5389e76

Browse files
author
Jimmy Mesta
committedFeb 11, 2019
spruce up
1 parent 9edd2d1 commit 5389e76

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed
 

‎001-Lab-Setup/README.md

+42-3
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,57 @@ In your home directory, we are going to pull in the documentation and source cod
3737
git clone https://github.com/ManicodeSecurity/Defending-DevOps/
3838
```
3939

40-
## Task 5: Explore your Kubernetes Cluster
40+
## Task 5: Connect to your Kubernetes Cluster
4141
Most of the tools necessary to complete the labs come pre-installed in Google Cloud Shell including `kubectl` which is used extensively to interact with your cluster. Ensure your cluster is operational by running the following commands.
4242

43-
First, we need to use `gcloud` to retrieve the credentials from the cluster in order to start interacting with it.
43+
First, we need to use connect to the cluster using Cloud Shell. In the navigation on the left, click `Kubernetes Engine -> Cluster` then click the `Connect` button next to your cluster:
4444

45+
![Cluster Connect](../images/gke-connect.png)
46+
47+
You will then be presented with options to connect to the cluster. Click `Run in Cloud Shell`. This will open Google Cloud Shell in the same browser tab. It will also paste a command into the terminal. All you need to do now is hit enter to run the command.
48+
49+
The command you are running will look like this:
4550
```
4651
gcloud container clusters get-credentials <YOUR-CLUSTER-NAME> --zone us-west1-a --project <YOUR-PROJECT-NAME>
4752
```
4853

54+
## Task 6: Interacting with the Cluster using `kubectl`
55+
56+
Helpful `kubectl` commands to interact with your cluster and its components:
57+
58+
### Retrieve Info about your cluster
59+
```
60+
# View your cluster credentials and location
61+
kubectl config view
62+
63+
# View list of services running on your cluster
64+
kubectl cluster-info
65+
66+
# View node info
67+
kubectl describe nodes
4968
```
69+
70+
### Interact with running pods
71+
```
72+
# Display all pods in all namespaces in the cluster
5073
kubectl get pods --all-namespaces
74+
75+
# Use -o wide to show more detail
76+
kubectl get pod -o wide --all-namespaces
77+
78+
# List all services running in the cluster
5179
kubectl get svc --all-namespaces
80+
81+
# Get a shell in a container within the pod
82+
kubectl exec -it <you-pod-name> --namespace=<namespace> /bin/bash
5283
```
5384

54-
We are now set up with an operational cluster.
85+
### View Logs
86+
```
87+
# View pods logs (first container in pod)
88+
kubectl logs <your-pod-name>
89+
90+
# View pod logs (specific container)
91+
kubectl logs <your-pod-name> -c <your-container-name>
92+
```
93+
For more useful `kubectl` commands check out the [kubectl cheat sheet](https://kubernetes.io/docs/reference/kubectl/cheatsheet/#interacting-with-nodes-and-cluster)

‎images/gke-connect.png

51.7 KB
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.