Christopher Blackden: Hello, today we're going to
go over how to set up a GitOps deployment workflow
using Jenkins x, Google Cloud Platform, and
Kubernetes. So first of all, I'm here in my Google
Cloud Platform. And I'm going to go ahead and open
up a Cloud Shell instance. And let's put that into
a new window to make sure we have enough space to
work on here. All right now, first things first, I
want to make sure that I'm in my project that I
want to do here, which is the GitOps demo project.
Perfect. Now next, we're going to go through and
get the Jenkins x binaries. Jenkins x is an
orchestrator that we're going to use to run this
whole project. And the command line tool for it is
Jenkins x.
They're fairly easy. It's just downloadling the
command line and then adding it to our bin
directory. But after that, we can test and see if
it worked by running JX, which is going to tell
us, we do have a working Jenkins x command line.
And we can clear that off now and start working on
creating our Kubernetes cluster. So the command to
do that is JX, create, cluster. And here it's
expecting an argument, usually the cloud provider
or on premise instance, you're setting up in your
Kubernetes cluster. Since we are on the Google
Kubernetes engine, we're going to use GKE. And
there's a little bit of a gotcha when we're using
Google Cloud Platform, we want to make sure we put
in the skip login flag as well. And that'll save
us some headache later on. So let's go ahead and
run that. All right, now that it's run a little
bit, it's asking us what type of cluster we want
to create. We're going to pick zonal for this
case. And as far as which zone, we wanted to play
it I'm in the eastern United States. So we're
going to go ahead and pick the US East one cloud
zone. And the Google Cloud Machine type is the
size of the nodes that you want Kubernetes to
generate, when it scales up and scales down. It's
worth noting that any one of these options, if you
type in a question mark, it will tell you a little
bit more about it, in some cases, even give you a
link to further documentation.
For this demo purpose, we're going to go ahead and
just use the defaults for everything including the
three minimum nodes and five maximum nodes. We're
not going to use preemptive VM or access the
Google Cloud Storage or Google Container Registry.
And we're not going to enable Kanico for building
container images. So now we've run through all of
those. it'll prompt us a little bit later on for
some next steps. But for now, let's just let the
cluster create in the background. Okay, now that's
run for a little while. It's going to ask us if we
want to set up an Ingress controller for our cube
system namespace, we definitely want to do this.
This is how we're going to interact with not only
Jenkins x, but our application as well. Next up,
we're being prompted to add a domain. This is if
we have a custom domain we want to use for our
application. If we don't, it will actually give us
an IP address on the nip.io domain, which is what
I'm going to choose for this. Next, we're being
prompted for an API token for GitHub. And we're
being given a URL to run here. So I'm going to go
ahead and do that in another window, and then
bring it up here. So this is my personal GitHub
account. And this is what that URL redirects to.
It's a personal access token that has already got
these permissions filled out. And what we need to
be able to do is generate a token here and give
that to Jenkins so that it can make modifications
to GitHub on our behalf. I'm going to go ahead and
generate the token and then copy it off. Then I
will go back to my Jenkins x installation, and
enter it from there. Okay, I've got my API token,
and I'm entering it now. So this does mean that in
order to set this up, you have to have the ability
to delegate at least repo level permissions on
your GitHub account. And yes, I'm going to select
the default and use GitHub as the pipeline to get
server. Next one, we select Jenkins installation
type, we want to pick our static Jenkins server
and Jenkins files.
Right. As for the default workload build pack,
we're going to go with the Kubernetes workloads
automated ci CD with GitOps promotion. All right
now that all that's been provisioned, it's given
us an admin password for our Jenkins instance,
we're going to go ahead and copy that off. And
next it's asking us to generate an API token. It's
logged into the Jenkins server. So let's go ahead
and go into admin and enter that password. There
we go. So now we have our Jenkins server. Let's go
back here and select the organization where we
want to create our environment files. We're going
to select dev by accident, because that is my
GitHub account. All right, and it looks like
that's been provisioned. Let's go to my GitHub and
see if anything's changed. So I'm back in my
GitHub account here. And it does have the two
environment folders, their staging and production
with the samurai bead, which is the name that GK
auto generated for us. Alright, so let's go back
to our Cloud Shell and see what else we could do.
Okay, so I'm back on my Cloud Shell window, I'm
going to go ahead and type in that command down
there. We're going to start a new micro service
from a quick start. So that is JX. Create Quick
Start, and we'll go ahead and use the get username
we set up earlier, the same organization and we'll
go ahead and call this Go Lang HTTP test. And out
of our choices here we have a several that we can
pick from, but we will pick our goal on HTTP
endpoint. And we will go ahead and initialize it,
and stick with the default message, which is
initial import. And I will let this run for a
minute. Now that that's done, let's go ahead and
see if we can run some of these basic commands.
I'll run a JX console, which will pull up our
Jenkins console here. All right, and we see we
have our go Lang HTTP test environment. And we
have a staging and production environments. Let's
go ahead and see if we can get the activity for
that. I'm going to go back to my Cloud Shell here
and run this first pipeline command here. We're
actually pending. So let's let that run for a
little bit and see if we can come back to it after
it's done. Alright, it looks like all our
deployments have succeeded. So I'm gone ahead and
gotten out of there, we can also run a JX get
applications. To see that we do have our going
HTTP test version one in staging. We have a pod,
one pod, excuse me, and we have the URL for it as
well. But it's not just enough to put it in
staging. Let's actually see if we can get this
into production. So if I run a list directory, I
see I have my go Lang HTTP test. Let's go ahead
and get into that. And then I'll run a Jax promote
go Lang. Alright, so let's break this down a
little bit. We have our JX promote go Lang HTTP
test, which is our application. We have the
version 00.1 which is the version we're going to
promote into production. And we want to specify
the environment which is production. So let's go
ahead and run that. Okay, so we've entered our the
username and password for my GitHub account, we
went to the password for my account, which since I
have two factor authentication on is an personal
access token. So that's something to keep in mind.
Let's go ahead and wait for this to finish.
Actually, let's do one better. Let's go ahead and
go into Jenkins and take a look at it. So you see
in my production environment, it's open to pull
request, and it's now validating the environment
and getting ready to deploy. All right, and that's
it. That's how we run a GitOps workflow from
Jenkins x in the Google Cloud engine. Thanks for
watching.