Димитар Георгиев

Create a bucket using the Cloud Console

Покупки 0 комментариев
Create a bucket using the Cloud Console
/*............................. Creating a Kubernetes Engine cluster  .................................    ......................*/
You can list the active account name with this command:
gcloud auth list 

You can list the project ID with this command::
gcloud config list project 

Set your default compute zone ::
gcloud config set compute/zone us-central1-a 
To create a cluster::
gcloud container clusters create [my-cluster] 
  
To authenticate the cluster run the following command::
gcloud container clusters get-credentials [my-cluster]

--> Create a new Deployment - hello-server 
Run the following kubectl create command in Cloud Shell to create 
hello-server 
from the hello-app container image::

kubectl create deployment hello-server --image=gcr.io/google-samples/hello-app:2.0

--> In this case, --image specifies a container image to deploy. The command pulls the example
image from a Google Container Registry bucket. gcr.io/google-samples/hello-app:1.0 indicates
the specific image version to pull.

--> Expose your application ::
kubectl expose deployment hello-server --type=LoadBalancer --port 8080 

type="LoadBalancer" creates a Compute Engine load balancer for your container. Inspect the hello-server ::

kubectl get service

--> Clean up: Delete the cluster
gcloud container clusters delete my-cluster

 

/*..........Set Up Network and HTTP Load Balancers ..............     ...................*/
This script sets up the Nginx server upon startup:

cat << EOF >> startup.sh
>  #! /bin/bash a
>  pt-get update 
>  apt-get install -y nginx 
>  service nginx start
>  sed -i -- 's/nginx/Google Cloud Platform - '"\$HOSTNAME"'/' 
>  /var/www/html/index.nginx-debian.html EOF
Create an instance template, which uses the startup script: 
gcloud compute instance-templates create nginx-template \
 --metadata-from-file startup-script=startup.sh

Create a target pool: 
gcloud compute target-pools create nginx-pool 

Create a managed instance group using the instance template: 
This creates 
2 virtual machine instances with names that are prefixed with nginx-. This
may take a couple of minutes::
gcloud compute instance-groups managed create nginx-group \
  --base-instance-name nginx \
  --size 2 \
  --template nginx-template \
  --target-pool nginx-pool
 

List the compute engine instances and you should see all of the instances created:
gcloud compute instances list 

Create a firewall rule to allow traffic (80/tcp)::
gcloud compute firewall-rules create www-firewall --allow tcp:80

Now configure a firewall so that you can connect to the machines on port 80 via
the EXTERNAL_IP addresses:

gcloud compute firewall-rules create www-firewall --allow tcp:80 

You should be able to connect to each of the instances via their external IP
addresses via http://35.202.4.198

/*..........Network load balancing.............. ................*/

Create an L3 network load balancer targeting your instance group:

gcloud compute forwarding-rules create nginx-lb \ 
> --region us-central1 \ 
> --ports=80 \
> --target-pool nginx-pool 

List all Google Compute Engine forwarding rules in your project:

gcloud compute forwarding-rules list

load balancer from the browser: http://IP_ADDRESS/

/*.......... HTTP(S) load balancing ............. .......................*/

HTTP(S) load balancing provides global load balancing for HTTP(S) requests destined
for your instances.
First, create a health check::
gcloud compute http-health-checks create http-basic-check

Create an instance template, which uses the startup script: 
gcloud compute instance-templates create nginx-template \
   --metadata-from-file startup-script=startup.sh

Create a target pool:
gcloud compute target-pools create nginx-pool

Create a firewall rule to allow traffic (80/tcp):: 
gcloud compute firewall-rules create www-firewall --allow tcp:80

// Create a health check
gcloud compute http-health-checks create http-basic-check

 

Now the load balancing service can forward traffic to the named port::
gcloud compute instance-groups managed \
     set-named-ports nginx-group \
     --named-ports http:80 

Create a backend service::
gcloud compute backend-services create nginx-backend \ 
 --protocol HTTP --http-health-checks http-basic-check --global 

Add the instance group into the backend service::
gcloud compute backend-services add-backend nginx-backend \ 
>   --instance-group nginx-group \ 
>   --instance-group-zone us-east1-b \ 
>   --global  

Create a URL map and target HTTP proxy to route requests to your URL map
gcloud compute url-maps create web-map \
--default-service nginx-backend
Create a default URL map that directs all incoming requests to all your instances: 

gcloud compute url-maps create web-map \ 
--default-service nginx-backend 

Create a target HTTP proxy to route requests to your URL map::
gcloud compute target-http-proxies create http-lb-proxy \ 
 --url-map web-map 


Create a global forwarding rule to handle and route incoming requests::
gcloud compute forwarding-rules create http-content-rule \
  --global \
  --target-http-proxy http-lb-proxy \
  --ports 80


gcloud compute forwarding-rules create http-content-rule A forwarding rule 

sends traffic to a specific target HTTP or HTTPS proxy depending on the IP address, 

Propagate a forwarding rule::
gcloud compute forwarding-rules list 

Take note of the http-content-rule IP_ADDRESS for the forwarding rule http://35.190.94.220

 

Назад Вперед
Войдите или зарегистрируйтесь
чтобы оставить комментарий