close

If you don't have your own domain name, you should use minikube instead.

KOPS can be easily installed on Mac directly, and you don't really need to have visualbox and vagrant.

brew update && brew install kops

 

If you would like to try my setup, first you have to install visualbox and vagrant on your MAC.  (Sorry, I don't have a window machine. )

1. make a new directory for setup a new linux vm by vagrant.  It is free to use other linux version like ubuntu, and in this example I use centos 7.

you could get some more idea here. (https://app.vagrantup.com/boxes/search?utf8=%E2%9C%93&sort=downloads&provider=&q=centos)

#mkdir centos7

2. initialize the vm environment by vagrant

#cd centos7; vagrant init centos/7

A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

3. boot up your centos7.  It will take some time at the firt time setup.

# vagrant up

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'centos/7' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'centos/7'
    default: URL: https://vagrantcloud.com/centos/7
==> default: Adding box 'centos/7' (v1801.02) for provider: virtualbox
    default: Downloading: https://vagrantcloud.com/centos/boxes/7/versions/1801.02/providers/virtualbox.box
==> default: Successfully added box 'centos/7' (v1801.02) for 'virtualbox'!
==> default: Importing base box 'centos/7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'centos/7' is up to date...
==> default: Setting the name of the VM: centos_default_1520566392857_91635
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key

    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default:
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
==> default: Rsyncing folder: /Users/xxxxx/Documents/vagrant/centos/ => /vagrant

4. check out your ssh-config, windows users might have some issues on the identity file.   it is easy to find solution by google "vagrant identityFile windows".

$ vagrant ssh-config
Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /Users/xxxxx/Documents/vagrant/centos/.vagrant/machines/default/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL

5. ssh to the centos machine, and you will see below linux prompt.

$vagrant ssh
[vagrant@localhost ~]$

6. download and install kops on your linux.  (https://github.com/kubernetes/kops)

curl -LO 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-linux-amd64
sudo mv kops-linux-amd64 /usr/local/bin/kops

 7. update your yum package by typing below comand, and it takes some time to complete. 

$sudo yum update

8. in order to use aws-cli, you have to install python pip  (https://www.liquidweb.com/kb/how-to-install-pip-on-centos-7/)

$sudo yum install python-pip

if you cannot install pip, you can try below commands:

curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"

sudo python get-pip.py

9. install aws-cli

[vagrant@localhost ~]$ sudo pip install awscli

10. you need to create an AWS account and configure it with the "awscli configure".  Prepare your keys.  You can download the key csv file after your create your IAM user.

[vagrant@localhost ~]$ aws configure
AWS Access Key ID [None]: AKTHISISEXAMPLEACCESSKEYP6OA
AWS Secret Access Key [None]: Othisisexamplesecretkeyjco
Default region name [None]: ap-northeast-1
Default output format [None]: json


[vagrant@localhost ~]$ ls ~/.aws/
config  credentials

Before you start using the aws service, make sure that you have set up the permission by the IAM policy.   In my case, I am using administration access.

11. create a new S3 bucket.  The bucket name must be globally unique.  

[vagrant@localhost ~]$ aws s3api create-bucket --bucket kops-state1234abc --region ap-northeast-1 --create-bucket-configuration LocationConstraint=ap-northeast-1
{
    "Location": "http://kops-state1234abc.s3.amazonaws.com/"
}

[vagrant@localhost ~]$ aws s3 ls
2018-03-09 05:38:31 kops-state.svc.litv.tv

12. Kops can also manage your domain name for kubernates usage.  You have to set up route53 as below:

Now your environment is ready!!  Let's do some more adventures in KOPS.

 

 

arrow
arrow

    webbhlin 發表在 痞客邦 留言(0) 人氣()