0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

メモ: Kubernetes @ GKEコマンド

Last updated at Posted at 2018-08-02

#create cluster
gcloud container clusters create k0

Launch a single instance:

kubectl run nginx --image=nginx:..*

#Get pods
kubectl get pods

Expose nginx

kubectl expose deployment nginx --port 80 --type LoadBalancer

#List services
kubectl get services
Kubernetes cheat sheet

Creating Pod
#Explore config file
cat pods/<app name>.yaml

Create the <app name> pod

kubectl create -f pods/<app name>.yaml
Examine pods
kubectl get pods

#get more information about the <app name> pod.

kubectl describe pods <app name>


interact with POd
#Cloud shell 1: set up port-forwarding
kubectl port-forward <app name> 10080:80

#Open new Cloud Shell session 2
curl http://127.0.0.1:10080
curl http://127.0.0.1:10080/secure

#Cloud shell 2 - log in
curl -u user http://127.0.0.1:10080/login
curl -H "Authorization: Bearer " http://127.0.0.1:10080/secure

View logs

kubectl logs <app name>
kubectl logs -f <app name>

#In Cloud Shell 3
curl http://127.0.0.1:10080
In Cloud Shell 2

#Exit log watching
(Ctrl-C)

run an interactive shell inside the <app name> Pod

kubectl exec <app name> --stdin --tty -c <app name> /bin/sh

#test external connectivity
ping -c 3 google.com

#logout
exit


Create secret

create the tls-certs secret from the TLS certificates stored under the tls directory

kubectl create secret generic tls-certs --from-file=tls/

#verify
kubectl describe secrets tls-certs

#create a configmap entry for the proxy.conf
kubectl create configmap nginx-proxy-conf --from-file=nginx/proxy.conf

#get more details about the nginx-proxy-conf configmap entry
kubectl describe configmap nginx-proxy-conf

Access a Secure HTTPS Endpoint
#Create the secure-<app name> Pod
kubectl create -f pods/secure-<app name>.yaml
kubectl get pods secure-<app name>
kubectl port-forward secure-<app name> 10443:443

curl --cacert tls/ca.pem https://127.0.0.1:10443

kubectl logs -c nginx secure-<app name>

#参照もと:
http://kubernetes.io/docs/user-guide/kubectl-cheatsheet/

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?