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

Creating a VM

Speakings 0 комментариев
Creating a VM
Cloud Shell using Google Cloud SDK command like gcloud and gsutil.
Эллен Димитриус “Читать человека как книгу”

Task : Create a persistent state in Cloud Shell o list available regions, execute
the following command: 

1.gcloud compute regions list 
Press Ctrl+OENTER to save the file, and then press Ctrl+X to exit nano.

Install a NGINX web server: 
sudo su - 
apt-get update 
apt-get install nginx -y 

Check that NGINX is running:  
ps auwx | grep nginx
  • Cloud Shell : 
    gcloud compute instances create gcelab2 --machine-type 
    > n1-standard-2 --zone \
    > us-central1-a
    
     --> Set the default region and zones :
    
    gcloud config set compute/zone us-central1-a
    gcloud config set compute/region us-central1 
    
    Finally, you can SSH into your instance : 
    gcloud compute ssh gcelab2
    
    Disconnect from SSH by exiting from the remote shell::
    exit
    
    What your default region and zone settings are::
    
    gcloud compute project-info describe --project 
    
    
    Make a couple of environment variables: 
    export PROJECT_ID=[project_id]
    
    Set your ZONE environment variable::
    export ZONE=us-central1-a
    
    Verify::
    echo $PROJECT_ID / echo $ZONE 
  • Create a virtual machine with gcloud using the Compute Engine API::
    
    gcloud compute, instances create ::
    
    gcloud compute instances create gcelab2 --machine-type n1-standard-2 --zone $ZONE 
    
    1. The name of the vm is "gcelab2", 
    2. You're using the --machine-type flag to specify the machine type as 
    "n1-standard-2"
    3. You're using the --zone flag
    4. machine type and image, if not specified in the create command, are set
    to default values.
    
    You can see the default values by displaying ::
    gcloud compute instances create --help  
    Type q to exit the content.
  • 3.To check how other properties are set, see all properties by calling::
    gcloud config list --all 
    
    To install or remove components at your current SDK version ::
    $ gcloud components install COMPONENT_ID 
    $ gcloud components remove COMPONENT_ID
    
    Install the beta components:: 
    
    gcloud components install beta
    gcloud beta interactive
  • 4. Use gcloud compute ssh to SSH into your vm:
    
    gcloud compute ssh gcelab2 --zone $ZONE
    Change your current working directory: cd $HOME ---> Not works!
    
    Open your .bashrc configuration file using vi ::
     vi ./.bashrc  
    ---> Press the ESC key and then :wq to exit the editor.
Назад Вперед
Войдите или зарегистрируйтесь
чтобы оставить комментарий