Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Latest commit

 

History

History
366 lines (268 loc) · 14.3 KB

File metadata and controls

366 lines (268 loc) · 14.3 KB

DukeCon Kubernetes / Jenkins-X Demo

You have some Dev or Ops background (or even both) and want to learn about one or all of the following?

  • Kubernetes (k8s) — the Cloud Operating System?

  • Jenkins-X (JX) — next generation k8s based CI/CD solution provided by the makers of the famous Jenkins server?

  • Development and deployment of a cloud native (distributed) application to k8s with the help of JX — by the example of DukeCon, the conference planner for Javaland and other community based conferences?

We will (currently) introduce you to experience these goals by some hands-on workshops and open space sessions, e.g., as Community Activity at Javaland 2020: DukeCon on JX.

No further knowledge of the above mentioned technologies is necessary to participate in the hands-on workshop!

Author JX Version

Gerd Aschemann

unknown

Important

Please prepare your participation in the hands-on workshop carefully by completing some setup steps as described in the Prerequisites.

The class does not require to be a Java developer, but some Java background will help to understand the examples.

Warning
This is currently not a complete online tutorial to introduce you to the mentioned technologies and goals. It only provides an introduction to enable you to participate in a hands-on session at one of the mentioned events.

Prerequisites

TL;DR

If you are experienced to run a local machine with OSX or Linux (even as a VM) and install and use developer and operator tools, you may directly jump to the respective installation and preparation parts for

Caution

Medium Level Skills minimum: The class is aiming at people with at least medium level development or operations experience. You should be used to work with tools like Git, a Shell and an IDE (optional, at least an editor like vi or emacs is required).

To take part of the hands-on session you need to prepare the following accounts and tools. You need to run some tools from either a local machine (Laptop), or a network (cloud) machine where you have shell access.

Github Account

During the workshop we will make heavy use of Github to store and share development and infrastructure projects. Therefore, you need to have a public Github account.

Note
Feel free to delete all the stuff from your Github account after you have finished the workshop.

If you do not have a Github account, create one (it’s free!).

Cloud Account

You need to have an account with one of the public cloud providers to participate in the workshop: Google (currently recommended), Microsoft, Amazon, or one of the many others who provide managed k8s. Almost all of them have a free plan, which allows to allocate the necessary resources (VMs, networks etc.).

Note
It is not required to have preliminary experience with these cloud environments — all the necessary knowledge is covered in the workshop.

K8s can be run on a great variety of public clouds as well as on-premises, and you probably have a private cloud with k8s already at hand? You may even consider running k8s on your local machine by Vagrant/VirtualBox, Qemu, or Minikube. JX also claims to run with an increasing number of cloud providers.

Nevertheless, from our experience the big cloud providers Google Cloud Platform (GCP) and Amazon Web Services (AWS) provide the best way to complete the examples. According to our experiences they both provide the most stable environments (for JX) and the fastest infrastructure. Please get yourself one of the following accounts and perform the necessary steps to install k8s and JX on your account.

Caution
In order to give optimal support to all participants of the hands-on sesseion we will only be able to help you if you make use of the mentioned cloud providers (i.e., GCP / GKE account). Local or private installations must not be used in the course of the session.

GCP / GKE account

Note
GKE

On the Google Cloud Platform we will use a managed Kubernetes, called Google Kubernetes Engine (GKE).

Create a Google cloud account if you do not already have one: https://cloud.google.com/

  • You need a Google user account if you do not have one already (may be created in the course of the cloud account setup),

  • Google provides a free plan for some time (cf. https://cloud.google.com/free/),

  • If you do not belong to the free plan any longer (if you already have used your free resources), running k8s / JX for only a few hours during the class will cost a few EURs (< 2 per hour).

AWS / EKS account

Important

Amazon Setup will be completed soon!

Shell and Tools

A (Unix) shell and some shell tools are necessary to participate in the workshop.

Note
If we talk of local tools or a local machine, a remote machine with shell access (e.g., via ssh or a Google Cloud shell) is also covered.
Tip
If you want to avoid all local installations we recommend to make use of the Google Cloud Shell of your GCP / GKE account. In this case you may skip the following installation steps: Switch to Google Cloud Shell and skip the remainder of this local installation section.

Your local machine does not need to be extremely powerful, though we recommend having at least 8 GB of RAM to run a local Java IDE (IntelliJ) if desired. The real work is performed by some cloud provider, e.g., GCP or AWS.

Caution

Local Administrator Rights required: You need to be able to run administrative tasks on your local or remote/ssh machine like performing the required Tool installation.

We strongly recommend to make use of a Unix-like operating systems, e.g., OSX (MacOS) or Linux.

Windows Users

If you need to work with Windows, you should at least have a bash (e.g., provided by git for Windows). Better results should be possible with Windows Linux Subsystem (WLS) as of current versions of Windows 10.

Note: We are not able to test a git bash or WLS based install due to a lack of access to a respective machine. If you have the possibility to run this setup with Win10, we are happy about a change request to this repository!

If all else fails please consider installing a small VM (2 GB RAM) with Linux (Ubuntu or Debian). You may use Vagrant (cf. Vagrant Setup) and VirtualBox to set it up.

If you have a remote Linux machine (in the cloud) available you may also use it. Please make sure you have your cloud credentials on this machine.

Tool installation

Please perform the following steps on your local machine (or remote via ssh login). We are not able to explain in detail the installation of the tools. You may use it as a first check if you are able to follow the class, iff you are able to complete the requirements section and install the tools and accounts.

If you run into any problems, please consider using Google Cloud Shell instead!

Getting started

Caution

If you can’t wait for the workshop day to start, you may proceed on your own risk from here.

Make sure you have at least completed the setup according to the Prerequisites so far!

Be aware that setting up infrastructure/resources in your cloud account may cause fees being charged to you depending on the kind of resources (machines, IPs, load balancers etc.) and if you have a free plan.

Remove resources when you’re done!

If you are finished with your work you probably want to remove your cloud resources in order to avoid being charged by the cloud provider, cf. Cleanup.

Get and start Docker container

  • Checkout (clone) this repository from https://github.com/dukecon/dukecon-jx-demo (or via ssh: github@github.com:dukecon/dukecon-jx-demo);

  • Go to the new directory: cd dukecon-jx-demo;

  • Set environment:

    export DUKECON_JX_VERSION=:latest
  • Get prepared JX Docker image

    docker-compose pull jx
  • Run prepared Docker image as new container

    docker-compose run jx
  • Optionally start screen within Docker container (to be able to start and switch to different shell sessions)

    screen

Prepare your Cloud Account

Log in to your cloud account and perform further setup

GKE
  • gcloud auth login # This will either open a browser session or show (a long) URL (please open with browser then) and follow instructions

  • Create a new project, e.g., jx-demo: gcloud projects create jx-demo

  • Check if the project is created with gcloud projects list

  • Set the new project as default: gcloud config set project jx-demo

  • Add a billing account to the new project: https://console.cloud.google.com/billing/

Create Jenkins X

Run the following command to get your first cluster going (you may follow almost all defaults of the interactive wizard):

GKE
  • jx create cluster gke --skip-login (make sure the login went well in the prepare step)

  • A setup wizard will start, use appropriate values, i.e.,

    • The project chosen in the Prepare your Cloud Account step,

    • In general confirm the defaults proposed by jx, except for the following,

    • Choose a region (hint: The U.S. regions are the cheapest regions, e.g., us-east1-b),

    • Use Static Jenkins Server and Jenkinsfiles installation type (this is not the default but we will make use of some features during the workshop)

    • Choose your name/email address from Github Account for the git user.

Appendix A: Google Cloud Shell

If you want to use Google Cloud Shell:

Tip
Skip Shell and Tools installation if you go this way; Proceed with Getting started.

Appendix B: Cleanup

Destroy Cloud Infrastructure

If you want to destroy your cluster, please perform the following commands.

GKE
  • gcloud container clusters list # Then check the name and zone (Location) of your created cluster here

  • gcloud container clusters delete -z <location> <name> # insert location and name

  • jx gc gke # This creates a local cleanup script gc_gke.sh

  • ./gc_gke.sh # Execute final cleanup

Hibernate Cloud Infrastructure

TBD

Appendix D: Manual (local) Tool Installation

If you want to install all tools provided by the JX Docker image locally (e.g. for testing), check out the Docker Installation Steps and call the respective scripts manually. Or look into the scripts and execute the installation on your own.

Docker Installation Steps
link:../../../docker/Dockerfile[role=include]

These scripts (setup/]) install the tools:

hub

is a nice CLI tool to work with GitHub from your local shell

screen (optional)

enables working with multiple shell sessions in parallel and allows to resume the shell sessions if your remote connection was broken. It is not only helpful if running on Vagrant and/or remote machine, but also to share environments for parallel terminal sessions (set environment variables once, then start screen).

helm

Is used internally as k8s package manager by Jenkins-X. You may need to use it occasionally, e.g., when tracking errors.

jx (Jenkins-X CLI)
gcloud

Used to interact with the Google Cloud API (used by JX, but also from you)

Note
If you are running on Google Cloud Shell this is already installed.

Some of the installers may install more tools if necessary, e.g.,

kubectl

Control your k8s from the CLI (https://kubernetes.io/docs/tasks/tools/install-kubectl/)

Appendix E: Vagrant Setup

We have prepared a Vagrant Virtual Machine setup for your convenience if you do not have the opportunity to run on OSX/Linux/Docker or if you do not want to leave any of the tools on your local machine. Just go to the root of this repository (your local clone of it) and run

  • ./bin/vagrant-up (may take some time if you have to download the vagrant box for the first time),

  • vagrant ssh to log into the new VM.

Proceed from here with the additional setup (cf. Prerequisites).