day-7-b-gcp basics for java dev
day-7-b-gcp basics for java dev
==========
2. cloud shell
4. REST api
External IP Addresses V2
Static IP Addresses
sudo su
apt update
apt install apache2
ls /var/www/html
echo "Hello World!"
echo "Hello World!" > /var/www/html/index.html
echo $(hostname)
echo $(hostname -i)
echo "Hello World from $(hostname)"
echo "Hello World from $(hostname) $(hostname -i)"
echo "Hello world from $(hostname) $(hostname -i)" > /var/www/html/index.html
sudo service apache2 start
Internal IP vs External IP
-------------------------
If we stop/restart our vm external ip changes :(
#!/bin/bash
apt update
apt -y install apache2
echo "Hello world from $(hostname) $(hostname -I)" > /var/www/html/index.html
gcloud init
select an proejct
gcloud config set project learning-gcp-rg-ukg
set project
gcloud config set project learning-gcp-rg-ukg
create VM
gcloud compute instances create learning-gcp-43 --machine-type f1-micro
describe instance
gcloud compute instances describe learning-gcp-43
creating bucket
gsutil mb gs://learning-gcp-using-cli
hello.py
def create_bucket(bucket_name):
"""Creates a new bucket."""
# bucket_name = "your-new-bucket-name"
storage_client = storage.Client()
bucket = storage_client.create_bucket(bucket_name)
python hello.py
updating system
sudo apt-get update
install docker
sudo apt-get install docker.io -y
To start the Docker service automatically when the instance starts, you can use the
following command:
sudo systemctl enable docker
Add your user to the Docker group to run Docker commands without 'sudo'
sudo usermod -a -G docker $(whoami)
Note that the change to the user’s group membership will not take effect until the
next time the user logs in. You can log out and log back in to apply the changes or
use the following command to activate the changes without logging out:
newgrp docker
inbound rule
install kubectl:
-----------------
https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/
install
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
If you do not have root access on the target system, you can still install kubectl
to the ~/.local/bin directory:
chmod +x kubectl
mkdir -p ~/.local/bin
mv ./kubectl ~/.local/bin/kubectl
# and then append (or prepend) ~/.local/bin to $PATH
install minkikube:
-----------------
https://minikube.sigs.k8s.io/docs/start/
minikube dashboard
other informations
----------------------
gcloud compute zones list
gcloud compute regions list
gcloud compute machine-types list