Google cloud

Материал из noname.com.ua
Перейти к навигацииПерейти к поиску

Заметки

  • gcloud init --console-only
  • gcloud container clusters list
 gcloud container clusters list
NAME                    ZONE           MASTER_VERSION  MASTER_IP       MACHINE_TYPE   NODE_VERSION  NUM_NODES  STATUS
amp-kubernetes-cluster  us-central1-b  1.4.8           104.198.73.45   n1-standard-2  1.4.7 *       5          RUNNING
k-poc-search-1          us-central1-b  1.4.8           104.198.72.131  n1-standard-4  1.4.7 *       4          RUNNING
k-poc-search-2          us-central1-b  1.5.2           104.154.220.59  n1-highmem-4   1.5.2         2          RUNNING
mmazur-sandbox-1        us-central1-b  1.5.2           104.198.34.251  n1-standard-1  1.5.2         3          RUNNING

Получить креденции (kubectl будет настроен автоматически)

  • gcloud container clusters get-credentials mmazur-sandbox-1
Fetching cluster endpoint and auth data.
kubeconfig entry generated for mmazur-sandbox-1.
kubectl get pods
No resources found.

Создать тестовый деплоймент

kubectl run hello-node --image=gcr.io/google-samples/node-hello:1.0 --port=8080
 kubectl expose deployment hello-node --type="NodePort"

Таким образом сервис будет доступен на всех нодах кластера на случайно выбранном порту

kubectl get service
NAME         CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
hello-node   10.3.246.117   <nodes>       8080:31824/TCP   1m
kubernetes   10.3.240.1     <none>        443/TCP          13m


kubectl  describe service hello-node
Name:			hello-node
Namespace:		default
Labels:			run=hello-node
Selector:		run=hello-node
Type:			NodePort
IP:			10.3.246.117
Port:			<unset>	8080/TCP
NodePort:		<unset>	31824/TCP
Endpoints:		10.0.0.4:8080
Session Affinity:	None


Внешний Port --> 31824


gcloud compute addresses create mmazur-test-address --region us-central1

gcloud compute addresses list
NAME                 REGION       ADDRESS          STATUS
mmazur-test-address  us-central1  104.154.132.207  RESERVED

Создание Load Balancer

Файрволл

Для того тото бы хелс чек работал нужно разрешить траффик от сети 130.211.0.0/22 (о чем написано в инструкции https://cloud.google.com/compute/docs/load-balancing/health-checks)
Создать правило с именем mmazur-lb

 gcloud compute firewall-rules  create mmazur-lb  --allow=tcp,udp,icmp  --source-ranges 130.211.0.0/22

Health Check

gcloud compute http-health-checks  create mmazur-test-health-check --check-interval="5s" --port=31824
Created [https://www.googleapis.com/compute/v1/projects/kohls-ecom-sandbox/global/httpHealthChecks/mmazur-test-health-check].
NAME                      HOST  PORT   REQUEST_PATH
mmazur-test-health-check        31824  /

gcloud compute http-health-checks  describe mmazur-test-health-check
checkIntervalSec: 5
creationTimestamp: '2017-02-07T02:33:30.454-08:00'
description: ''
healthyThreshold: 2
host: ''
id: '2338322503345380501'
kind: compute#httpHealthCheck
name: mmazur-test-health-check
port: 31824
requestPath: /
selfLink: https://www.googleapis.com/compute/v1/projects/kohls-ecom-sandbox/global/httpHealthChecks/mmazur-test-health-check
timeoutSec: 5
unhealthyThreshold: 2


backend-services

Ссылки=

* http://containertutorials.com/get_started_kubernetes/k8s_example.html