Google cloud: различия между версиями
Материал из noname.com.ua
Перейти к навигацииПерейти к поискуSirmax (обсуждение | вклад) |
Sirmax (обсуждение | вклад) |
||
Строка 108: | Строка 108: | ||
===backend-services=== |
===backend-services=== |
||
+ | <PRE> |
||
+ | gcloud compute backend-services create mmazur-test-backend-service --http-health-checks mmazur-test-health-check |
||
+ | Created [https://www.googleapis.com/compute/v1/projects/kohls-ecom-sandbox/global/backendServices/mmazur-test-backend-service]. |
||
+ | NAME BACKENDS PROTOCOL |
||
+ | mmazur-test-backend-service HTTP |
||
+ | </PRE> |
||
+ | |||
+ | <PRE> |
||
+ | gcloud compute backend-services describe mmazur-test-backend-service |
||
+ | affinityCookieTtlSec: 0 |
||
+ | connectionDraining: |
||
+ | drainingTimeoutSec: 0 |
||
+ | creationTimestamp: '2017-02-07T02:40:16.526-08:00' |
||
+ | description: '' |
||
+ | enableCDN: false |
||
+ | fingerprint: y_d4_k-DcCA= |
||
+ | healthChecks: |
||
+ | - https://www.googleapis.com/compute/v1/projects/kohls-ecom-sandbox/global/httpHealthChecks/mmazur-test-health-check |
||
+ | id: '7566473235126295295' |
||
+ | kind: compute#backendService |
||
+ | loadBalancingScheme: EXTERNAL |
||
+ | name: mmazur-test-backend-service |
||
+ | port: 80 |
||
+ | portName: http |
||
+ | protocol: HTTP |
||
+ | selfLink: https://www.googleapis.com/compute/v1/projects/kohls-ecom-sandbox/global/backendServices/mmazur-test-backend-service |
||
+ | sessionAffinity: NONE |
||
+ | timeoutSec: 30 |
||
+ | |||
+ | |||
+ | </PRE> |
||
+ | |||
+ | <PRE> |
||
+ | gcloud compute backend-services get-health mmazur-test-backend-service |
||
+ | Listed 0 items. |
||
+ | |||
+ | |||
+ | </PRE> |
||
+ | |||
+ | <PRE> |
||
+ | gcloud compute instance-groups list |
||
+ | NAME LOCATION SCOPE NETWORK MANAGED INSTANCES |
||
+ | <SKIP> |
||
+ | gke-mmazur-test-2-default-pool-36fd4440-grp us-central1-b zone default Yes 3 |
||
+ | <SKIP> |
||
+ | </PRE> |
||
+ | |||
+ | |||
+ | <PRE> |
||
+ | |||
+ | |||
+ | gcloud compute backend-services add-backend mmazur-test-backend-service --instance-group=gke-mmazur-test-2-default-pool-36fd4440-grp --balancing-mode=UTILIZATION --max-utilization="1.0" |
||
+ | WARNING: This backend service is assumed to be global. To access a regional backend service, provide the --region flag. |
||
+ | In the future, backend services will be regional by default unless the --global flag is specified. |
||
+ | Updated [https://www.googleapis.com/compute/v1/projects/kohls-ecom-sandbox/global/backendServices/mmazur-test-backend-service]. |
||
+ | </PRE> |
||
+ | |||
+ | |||
+ | <PRE> |
||
+ | gcloud compute backend-services get-health mmazur-test-backend-service |
||
+ | WARNING: This backend service is assumed to be global. To access a regional backend service, provide the --region flag. |
||
+ | In the future, backend services will be regional by default unless the --global flag is specified. |
||
+ | --- |
||
+ | backend: https://www.googleapis.com/compute/v1/projects/kohls-ecom-sandbox/zones/us-central1-b/instanceGroups/gke-mmazur-test-2-default-pool-36fd4440-grp |
||
+ | status: |
||
+ | kind: compute#backendServiceGroupHealth |
||
+ | </PRE> |
||
==Ссылки=== |
==Ссылки=== |
Версия 12:50, 7 февраля 2017
Заметки
- 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
gcloud compute backend-services create mmazur-test-backend-service --http-health-checks mmazur-test-health-check Created [https://www.googleapis.com/compute/v1/projects/kohls-ecom-sandbox/global/backendServices/mmazur-test-backend-service]. NAME BACKENDS PROTOCOL mmazur-test-backend-service HTTP
gcloud compute backend-services describe mmazur-test-backend-service affinityCookieTtlSec: 0 connectionDraining: drainingTimeoutSec: 0 creationTimestamp: '2017-02-07T02:40:16.526-08:00' description: '' enableCDN: false fingerprint: y_d4_k-DcCA= healthChecks: - https://www.googleapis.com/compute/v1/projects/kohls-ecom-sandbox/global/httpHealthChecks/mmazur-test-health-check id: '7566473235126295295' kind: compute#backendService loadBalancingScheme: EXTERNAL name: mmazur-test-backend-service port: 80 portName: http protocol: HTTP selfLink: https://www.googleapis.com/compute/v1/projects/kohls-ecom-sandbox/global/backendServices/mmazur-test-backend-service sessionAffinity: NONE timeoutSec: 30
gcloud compute backend-services get-health mmazur-test-backend-service Listed 0 items.
gcloud compute instance-groups list NAME LOCATION SCOPE NETWORK MANAGED INSTANCES <SKIP> gke-mmazur-test-2-default-pool-36fd4440-grp us-central1-b zone default Yes 3 <SKIP>
gcloud compute backend-services add-backend mmazur-test-backend-service --instance-group=gke-mmazur-test-2-default-pool-36fd4440-grp --balancing-mode=UTILIZATION --max-utilization="1.0" WARNING: This backend service is assumed to be global. To access a regional backend service, provide the --region flag. In the future, backend services will be regional by default unless the --global flag is specified. Updated [https://www.googleapis.com/compute/v1/projects/kohls-ecom-sandbox/global/backendServices/mmazur-test-backend-service].
gcloud compute backend-services get-health mmazur-test-backend-service WARNING: This backend service is assumed to be global. To access a regional backend service, provide the --region flag. In the future, backend services will be regional by default unless the --global flag is specified. --- backend: https://www.googleapis.com/compute/v1/projects/kohls-ecom-sandbox/zones/us-central1-b/instanceGroups/gke-mmazur-test-2-default-pool-36fd4440-grp status: kind: compute#backendServiceGroupHealth
Ссылки=
* http://containertutorials.com/get_started_kubernetes/k8s_example.html