Monday, November 9, 2020

Install Docker application into Google Cloud k8s

 HOWTO

https://www.udemy.com/course/docker-and-kubernetes-the-complete-guide/

GitHub repo

https://github.com/StephenGrider/multi-k8s/blob/master/.travis.yml

https://github.com/dveselka/devops-k8s/blob/main/.travis.yml

 

Install Google Cloud SDK CLI

[dave@dave git]$ sudo tee -a /etc/yum.repos.d/google-cloud-sdk.repo << EOM
> [google-cloud-sdk]
> name=Google Cloud SDK
> baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64
> enabled=1
> gpgcheck=1
> repo_gpgcheck=1
> gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
>        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
> EOM
[sudo] password for dave: 
[google-cloud-sdk]
name=Google Cloud SDK
baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
       https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
[dave@dave git]$ sudo dnf install google-cloud-sdk
Google Cloud SDK                                                                                                                                                   364  B/s | 454  B     00:01    
Google Cloud SDK                                                                                                                                                    15 kB/s | 1.8 kB     00:00    
Importing GPG key 0xA7317B0F:
 Userid     : "Google Cloud Packages Automatic Signing Key <gc-team@google.com>"
 Fingerprint: D0BC 747F D8CA F711 7500 D6FA 3746 C208 A731 7B0F
 From       : https://packages.cloud.google.com/yum/doc/yum-key.gpg
Is this ok [y/N]: y
Importing GPG key 0xBA07F4FB:
 Userid     : "Google Cloud Packages Automatic Signing Key <gc-team@google.com>"
 Fingerprint: 54A6 47F9 048D 5688 D7DA 2ABE 6A03 0B21 BA07 F4FB
 From       : https://packages.cloud.google.com/yum/doc/yum-key.gpg
Is this ok [y/N]: y
Google Cloud SDK                                                                                                                                                   6.7 kB/s | 975  B     00:00    
Importing GPG key 0x3E1BA8D5:
 Userid     : "Google Cloud Packages RPM Signing Key <gc-team@google.com>"
 Fingerprint: 3749 E1BA 95A8 6CE0 5454 6ED2 F09C 394C 3E1B A8D5
 From       : https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
Is this ok [y/N]: y
Google Cloud SDK                                                                                                                                                   7.0 MB/s |  22 MB     00:03    
Last metadata expiration check: 0:00:06 ago on Mon 09 Nov 2020 07:32:03 PM CET.
Dependencies resolved.
===================================================================================================================================================================================================
 Package                                            Architecture                             Version                                      Repository                                          Size
===================================================================================================================================================================================================
Installing:
 google-cloud-sdk                                   x86_64                                   317.0.0-1                                    google-cloud-sdk                                    72 M

Transaction Summary
===================================================================================================================================================================================================
Install  1 Package

Total download size: 72 M
Installed size: 359 M
Is this ok [y/N]: 


 

Init Google Cloud CLI

[dave@dave git]$ gcloud init
Welcome! This command will take you through the configuration of gcloud.

Your current configuration has been set to: [default]

You can skip diagnostics next time by using the following flag:
  gcloud init --skip-diagnostics

Network diagnostic detects and fixes local network connection issues.
Checking network connection...done.                                                                                                                                                               
Reachability Check passed.
Network diagnostic passed (1/1 checks passed).

You must log in to continue. Would you like to log in (Y/n)?


Install Travis CLI

     $ sudo dnf install ruby 

     $ ruby --version
    ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]

    git clone https://github.com/travis-ci/travis.rb
    Cloning into 'travis.rb'...

Install travis

$ gem install travis  
Fetching multipart-post-2.1.1.gem
Fetching ruby2_keywords-0.0.2.gem
Fetching faraday-1.1.0.gem
Fetching faraday_middleware-1.0.0.gem
Fetching highline-2.0.3.gem
Fetching concurrent-ruby-1.1.7.gem
Fetching i18n-1.8.5.gem
Fetching thread_safe-0.3.6.gem
Fetching tzinfo-1.2.8.gem
Fetching minitest-5.14.2.gem
Fetching activesupport-5.2.4.4.gem
Fetching multi_json-1.15.0.gem
Fetching public_suffix-4.0.6.gem
Fetching addressable-2.7.0.gem
Fetching net-http-persistent-2.9.4.gem
Fetching net-http-pipeline-1.0.1.gem
Fetching travis-1.10.0.gem
Fetching gh-0.18.0.gem
Fetching launchy-2.4.3.gem
Fetching json_pure-2.3.1.gem
Fetching websocket-1.2.8.gem
Fetching pusher-client-0.6.2.gem
Successfully installed multipart-post-2.1.1
Successfully installed ruby2_keywords-0.0.2
Successfully installed faraday-1.1.0
Successfully installed faraday_middleware-1.0.0
Successfully installed highline-2.0.3
Successfully installed concurrent-ruby-1.1.7

HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
But that may break your application.

If you are upgrading your Rails application from an older version of Rails:

Please check your Rails app for 'config.i18n.fallbacks = true'.
If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
'config.i18n.fallbacks = [I18n.default_locale]'.
If not, fallbacks will be broken in your app by I18n 1.1.x.

If you are starting a NEW Rails application, you can ignore this notice.

For more info see:
https://github.com/svenfuchs/i18n/releases/tag/v1.1.0

Successfully installed i18n-1.8.5
Successfully installed thread_safe-0.3.6
Successfully installed tzinfo-1.2.8
Successfully installed minitest-5.14.2
Successfully installed activesupport-5.2.4.4
Successfully installed multi_json-1.15.0
Successfully installed public_suffix-4.0.6
Successfully installed addressable-2.7.0
Successfully installed net-http-persistent-2.9.4
Successfully installed net-http-pipeline-1.0.1
Successfully installed gh-0.18.0
Successfully installed launchy-2.4.3
Successfully installed json_pure-2.3.1
Successfully installed websocket-1.2.8
Successfully installed pusher-client-0.6.2
Successfully installed travis-1.10.0
Parsing documentation for multipart-post-2.1.1
Installing ri documentation for multipart-post-2.1.1
Parsing documentation for ruby2_keywords-0.0.2
Installing ri documentation for ruby2_keywords-0.0.2
Parsing documentation for faraday-1.1.0
Installing ri documentation for faraday-1.1.0
Parsing documentation for faraday_middleware-1.0.0
Installing ri documentation for faraday_middleware-1.0.0
Parsing documentation for highline-2.0.3
Installing ri documentation for highline-2.0.3
Parsing documentation for concurrent-ruby-1.1.7
Installing ri documentation for concurrent-ruby-1.1.7
Parsing documentation for i18n-1.8.5
Installing ri documentation for i18n-1.8.5
Parsing documentation for thread_safe-0.3.6
Installing ri documentation for thread_safe-0.3.6
Parsing documentation for tzinfo-1.2.8
Installing ri documentation for tzinfo-1.2.8
Parsing documentation for minitest-5.14.2
Installing ri documentation for minitest-5.14.2
Parsing documentation for activesupport-5.2.4.4
Installing ri documentation for activesupport-5.2.4.4
Parsing documentation for multi_json-1.15.0
Installing ri documentation for multi_json-1.15.0
Parsing documentation for public_suffix-4.0.6
Installing ri documentation for public_suffix-4.0.6
Parsing documentation for addressable-2.7.0
Installing ri documentation for addressable-2.7.0
Parsing documentation for net-http-persistent-2.9.4
Installing ri documentation for net-http-persistent-2.9.4
Parsing documentation for net-http-pipeline-1.0.1
Installing ri documentation for net-http-pipeline-1.0.1
Parsing documentation for gh-0.18.0
Installing ri documentation for gh-0.18.0
Parsing documentation for launchy-2.4.3
Installing ri documentation for launchy-2.4.3
Parsing documentation for json_pure-2.3.1
Installing ri documentation for json_pure-2.3.1
Parsing documentation for websocket-1.2.8
Installing ri documentation for websocket-1.2.8
Parsing documentation for pusher-client-0.6.2
Installing ri documentation for pusher-client-0.6.2
Parsing documentation for travis-1.10.0
Installing ri documentation for travis-1.10.0
Done installing documentation for multipart-post, ruby2_keywords, faraday, faraday_middleware, highline, concurrent-ruby, i18n, thread_safe, tzinfo, minitest, activesupport, multi_json, public_suffix, addressable, net-http-persistent, net-http-pipeline, gh, launchy, json_pure, websocket, pusher-client, travis after 15 seconds
22 gems installed

 
Login to travis

[dave@dave bin]$ travis login
Shell completion not installed. Would you like to install it now? |y| y
We need your GitHub login to identify you.
This information will not be sent to Travis CI, only to api.github.com.
The password will not be displayed.

Try running with --github-token or --auto if you don't want to enter your password anyway.

Username: dveselka 
Password for dveselka: ********
Successfully logged in as dveselka!

Encrypt service account for Travis
[dave@dave complex]$ travis encrypt-file service-account.json -r dveselka/devops-k8s
encrypting service-account.json for dveselka/devops-k8s
storing result as service-account.json.enc
storing secure env variables for decryption

Please add the following to your build script (before_install stage in your .travis.yml, for instance):

    openssl aes-256-cbc -K $encrypted_9f3b5599b056_key -iv $encrypted_9f3b5599b056_iv -in service-account.json.enc -out service-account.json -d

Pro Tip: You can add it automatically by running with --add.

Make sure to add service-account.json.enc to the git repository.
Make sure not to add service-account.json to the git repository.
Commit all changes to your .travis.yml.

Configure GCP project names and zone

 https://cloud.google.com/compute/docs/regions-zones 

 

Create account on https://hub.docker.com/

 

 Check Travis builds  

https://travis-ci.org/github/dveselka/devops-k8s/builds

 Add k8s secret using GCP shell

 

  Set Postgress password

daniel_veselka@cloudshell:~ (genial-acronym-295114)$  kubectl create secret generic pgpassword --from-literal POSTGRESS_PASSWORD=password123
secret/pgpassword created

No comments:

Post a Comment