Wednesday, 5 February 2020

Setup / Install Kubernetes environment


1. install jq (Json Parsor)
  - sudo apt install -y jq
   # check
   jq

2. install docker ( https://docs.aws.amazon.com/ko_kr/AmazonECS/latest/developerguide/docker-basics.html)
  - sudo yum update -y
  - sudo amazon-linux-extras install docker
  - (start docker) sudo service docker start
  - sudo usermod -a -G docker ec2-user
  - sudo reboot
  - docker version

3. install docker-compose
  - sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  - sudo chmod +x /usr/local/bin/docker-compose
  - docker-compose version


4. Install kops
wget -O kops https://github.com/kubernetes/kops/releases/download/$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-linux-amd64
chmod +x ./kops
sudo mv ./kops /usr/local/bin/

5. Install kubectl
wget -O kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl

6. IAM control Option
 - Please assgin to the user for
AmazonEC2FullAccess
AmazonRoute53FullAccess
AmazonS3FullAccess
IAMFullAccess
AmazonVPCFullAccess

7. install aws cli
sudo yum update
sudo yum install -y python-pip
pip install awscli

8. Setup your configuration
aws configure
AWS Access Key ID [None]:
AWS Secret Access Key [None]:
Default region name [None]: ap-northeast-2
Default output format [None]:

- aws configuration test
aws ec2 describe-instances
aws iam list-users
aws s3 ls

9. test command
- kops
- kubectl

Tuesday, 21 January 2020

Linux alias option command & and install telnet tool

alias k='kubectl'

k


---- Install telnet tool in shell script
apk add curl busybox-extras

Linux password change command

1. To change a password for user named tom in Ubuntu, type:
sudo passwd tom

2. To change a password for root user on Ubuntu Linux, run:
sudo passwd root

3. And to change your own password for Ubuntu, execute:
passwd

Monday, 20 January 2020

Linux - Kill port

netstat -nlp | grep 8000

sudo fuser -k 8000/tcp

netstat -nlp | grep 8000

Tuesday, 14 January 2020

- Install & run "Visual Studio Code Server" in Ubuntu

1. run this command
wget https://github.com/cdr/code-server/releases/download/2.1688-vsc1.39.2/code-server2.1688-vsc1.39.2-linux-x86_64.tar.gz
tar xvfz code-server2.1688-vsc1.39.2-linux-x86_64.tar.gz
sudo mv code-server2.1688-vsc1.39.2-linux-x86_64/code-server /usr/local/bin
mkdir ~/project
sudo curl https://gist.githubusercontent.com/subicura/d025000486d30d92dfa6ccc523c3f5e3/raw/2e93bb0dca992523a3e3a6fdba95d2f3526c52db/codeserver.service -o /lib/systemd/system/codeserver.service
sudo systemctl start codeserver
sudo systemctl enable codeserver

2. check your port
ubuntu@ip-172-26-0-243:~$ sudo systemctl status codeserver
● codeserver.service - Code Server IDE
   Loaded: loaded (/lib/systemd/system/codeserver.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2020-01-15 01:51:52 UTC; 1min 56s ago
 Main PID: 4755 (code-server)
    Tasks: 23 (limit: 4704)
   CGroup: /system.slice/codeserver.service
           ├─4755 /usr/local/bin/code-server --port 8000 /home/ubuntu/project
           └─4777 /usr/local/bin/code-server --port 8000 /home/ubuntu/project

> 8080 is the port or VS Code Server

3. Access server http:/111.111.111.111:8080
4. move directory and get password

ubuntu@ip-172-26-0-243:~$ cd project

ubuntu@ip-172-26-0-243:~$ PASSWORD=1q2w3e4r nohup code-server -p 8000 --allow-http &

ubuntu@ip-172-26-0-243:~$ nohup: ignoring input and appending output to 'nohup.out'

5. access  server http:/111.111.111.111:8080 - Password - 1q2w3e4r (login)
 
==========  ReStart ===================================

* Restart Visual Studio Code Server
ubuntu@ip-172-26-0-243:~$ rm -r project

ubuntu@ip-172-26-0-243:~$ cd project

ubuntu@ip-172-26-0-243:~$ PASSWORD=1q2w3e4r nohup code-server -p 8000 --allow-http &

access  server http:/111.111.111.111:8080 - Password - 1q2w3e4r (login)


- Install and run wetty in Ubuntu 18.04 LTS ( with Amazon Lightsail )

- Install and run wetty in Ubuntu 18.04 LTS ( with Amazon Lightsail )

org : https://www.youtube.com/watch?v=4T6wKk_ZWCM

1. Go to Amazon Lightsail
2. Create Instance
3. OS only -> Ubuntu 18.04 LTS
4. $20 > 4TB
4-1. put below user data ( Add launch script )
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
echo "ubuntu:1q2w3e4r" | chpasswd

5. Create Instance
  - put this script under "Add launch script"
   sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
echo "ubuntu:1q2w3e4r" | chpasswd
service sshd reload

6. Go into the instance and change the network to "All TCP"
7. copy ip of new instane and try to access from browser
   http://http://13.231.170.42:4200/
   Fail - cannot access
8. Go to "Connect" and "Connect using SSH"
9. run below command one by one

sudo service sshd reload

sudo apt-get -y update

sudo apt-get -y install nodejs npm

sudo npm install -g wetty

sudo curl https://gist.githubusercontent.com/subicura/9058671c16e2abd36533fea2798886b0/raw/e5d249612711b14c9c8f44798dea1368395e86a9/wetty.service -o /lib/systemd/system/wetty.service

sudo systemctl start wetty

sudo systemctl enable wetty

10. Access again with ip : http://http://13.231.170.42:4200/
id : ubuntu - Pw : 1q2w3e4r

Wednesday, 8 January 2020