Okay, let's go ahead and head back to the Deployment.yaml for the notification service, where we're
going to go ahead and add some environment variables for this deployment.
And let's go ahead and define a new field here called ports and define a container port.
So this is going to be the port that we're going to allow connections on inside of this pod.
In this case, we will use Port 3000.
So now we've told Kubernetes which port we're connecting on, we need to tell the actual pod itself
through the environment variable.
Let's go ahead and do this with the environment variable section and we'll go ahead and define a new
environment variable named port, and we'll provide the value at Port 3000.
Next, we need to provide our Google OAuth environment variables.
So let's go ahead and provide the ones that don't need to be secret First, we'll start off with the
Google OAuth client ID and set the value equal to the dot env from our notifications dot env file.
We can copy this value over and paste it in as plain text.
We can do the same thing for the Smtp user.
We'll go ahead and set the value from our M file as the sleeper Nest app at gmail.com.
Now we need to create two secrets for our client secret as well as the refresh token as these are sensitive
values.
So we'll create these secrets the same way we have before by running kubectl.
Create secret and I'll call this Google.
Then we're going to specify from literal and set equals client secret and set that equal to the client
secret.
From our dot env file and we'll simply paste this in.
Then we'll go ahead and add another from literal flag where we'll set the refresh token key equal to
our refresh token.
So we'll go ahead and copy this value as well.
And paste that in.
Additionally, don't forget we need to add the generic keyword.
So after kubectl create secret, we will add generic to make this secret a generic type.
And then we'll go ahead and enter this to create this secret.
Now that we've created the secret, we need to reference it securely.
So we'll go ahead and do this by firstly providing the name Google OAuth client secret.
This will be set to value from secret key Ref.
And we give this the name of our secret, which is Google.
And then the key we specified this under which was client secret.
We'll go ahead and copy this because it's going to be the same process to specify the Google OAuth refresh
token.
We just need to change out the client secret for the refresh token and also make sure we change the
secret key ref.
We keep the existing name of it, but then the key has to change to refresh token.
Now we can go back and run helm Upgrade Sleeper to go ahead and upgrade our deployment.
If we go ahead and run Kubectl get Pods, we should see the notification pods start up and if we run
logs on it, we can see it has successfully started up.
So next we want to create a service for our notifications deployment so that our other pods can easily
talk to it in our Kubernetes cluster in a reliable way.
So let's go ahead and CD into our templates folder and then CD into notifications.
So let's go ahead and run Kubectl, create service cluster IP, and we'll call this notifications and
we'll go ahead and specify the TCP argument here and we're going to set the port to 3000.
We will set dry run equal to client so we don't actually create this and we'll set the output to Yaml
and pipe this to a service dot yaml file.
Now if we go ahead and look at the newly created file here in notifications, we can see we have everything
we need to create a new cluster IP service.
So I'll go ahead and remove the status section here as well as the creation timestamp.
You can see here we have a port on TCP protocol at Port 3000 that's going to target port 3000 on the
pod, which is exactly what we want.
So now if we go back up to the root helm and run helm upgrade Sleeper again, we should be able to then
run Kubectl, get service and see our new notification service.
Okay, so let's move on to the payment service.
Next, you can see the environment variables we need to supply.
So let's go ahead and get started.
We will go into the payments deployment and let's go ahead and firstly start off by adding the container
port as we've done before.
I'll go ahead and add a new section called Ports and add a container port, and we'll specify this at
Port 3001.
Next, let's go ahead and specify our environment variable block.
We'll go ahead and specify our first environment variable and we will specify the port and give it a
value of 3001.
Next, you can see we need to tell it where the notifications host and port is and we know exactly where
that is because of the service we just created.
So let's go ahead and specify the notifications.
Host This value is going to be just notifications because that's the name of the service we created
and that's how Kubernetes services talk to each other.
This will be the host name here.
And of course we know the port is 3000 as we just defined.
So we can go ahead and specify the notifications port now and give this a value of 3000.
Finally, we need to specify the stripe secret key.
And again, we of course don't want to commit any values that contain this.
We would never be committing these dot m files to a repository.
I have done this merely to make it easier for you.
However, in reality we wouldn't be committing these files.
And so we need a way to secretly hide these in our Kubernetes cluster.
And that's what we'll go ahead and do.
As we did with the MongoDB.
We'll create a new secret here for the Stripe key.
So go ahead and copy your existing stripe secret key and then we can go ahead and run kubectl, create
secret generic again, we'll call it Stripe and it will be from literal.
Again, we can specify an API key here and paste in our API key.
We can go ahead and copy our existing code to extract the MongoDB secret.
And let's go ahead and paste that in.
To our existing EMF block.
We simply need to change the secret key name to Stripe.
And then we'll change the key to API key.
Finally, we need to change the environment variable to stripe secret key.
Let's go ahead and redeploy our deployments now by running Helm Upgrade Sleeper again.
Now if we run Kubectl get pods, we can see the payments.
Pod is now up and running and it is no longer crashing.
If we look at the logs, we can see it has also started up successfully.
Okay, so now we're on to the auth service.
We've already defined the MongoDB Uri.
Let's go ahead and firstly take care of the JWT secret that we need to define here.
Again, just like the stripe secret key.
I'll take this from our existing env.
We'll go ahead and copy this existing secret, then we'll go ahead and run kubectl, create secret generic
and I'll call this JWT.
We'll pass from literal.
I'll set it equal to JWT secret and paste in our JWT secret.
Now let's go back in our folder.
Under the auth deployment, we can go ahead and copy this existing block for the MongoDB Uri as we've
done before.
Paste that in and we'll go ahead and swap this out for the JWT secret value.
Change the name here to JWT and the key to JWT secret.
So now we're defining the JWT secret from our new secret.
Next, we'll define a JWT expiration.
So this will not be a secret.
We can just go ahead and define this directly, and I will use the same value as before as 3600 seconds.
Next, we need to define both of our Http port and TCP port.
So as we've done before when defining ports, let's open up a new section here called ports.
We can go ahead and define a new container port and we'll go ahead and use 3002 for our TCP port.
And we also need a port for our Http server.
So we'll use 3003 for this.
Let's go ahead and define these ports in our environment variable.
Firstly, we will do the TCP port and give it a value of 3002 and then we'll have our Http port here
and give it a value of 3003.
Let's go ahead and run helm upgrade again.
Now if we run Kubectl get pods, we can see our auth pod is now up and running and both our nest application
over Http has started as well as our microservice over TCP.
Let's go ahead and generate our service for our payments deployment.
We'll go ahead and make sure we're in the payments folder in our templates directory.
We'll go ahead and run Kubectl, create service cluster IP and call this payments.
We'll go ahead and specify TCP port at 3001.
Set the dry run equal to client, specify the outputs Yaml and pipe this to a service dot yaml file.
Now you can see we have our newly created payment service that is going to direct traffic on port 3001
to the pod port at 3001.
I'll go ahead and remove the status and the creation timestamp.
Okay.
So we need to generate the service for the auth deployment.
Now let's go ahead and run kubectl, create service cluster IP auth.
We're going to go ahead and specify the TCP equal to 3002 and comma 3003 so that we can open up two
ports on this service because of course, if you remember, auth will have two ports, one for Http
and one for our microservice over TCP.
We'll set the dry run equal to client output Yaml and spit this out to a service dot yaml file.
Now if we look at the services yaml for auth you can see we have two ports open up exactly as we designed.
We'll go ahead and remove the status and the creation timestamp.
Finally, we're ready to set up our reservations deployment and you can see all the environment variables
we need to define now.
So open up the reservations deployment.
Of course, we know we have the MongoDB Uri already specified.
Let's go ahead and set up a port for the reservation service itself.
We'll go ahead and specify a ports section and I'll give it a container port at 3004.
Let's go ahead and specify this environment variable name of port and give it a value of 3004.
Now we need to specify the auth host and port.
So let's go ahead and do that.
Next, we know the name of the auth service.
We know the name will be auth host and of course we know the value will be the name of the author.
Service.
And so we know if you run kubectl get service, the auth service hostname will be auth.
So we'll go ahead and provide the name auth and the auth port with a value.
So for the auth port we want to make sure that we're using the TCP port and not the Http one because
we're communicating through the microservice layer.
So to confirm this, we can go ahead and look at what we defined in the auth deployment.
Well, the TCP port is at 3002, so let's go ahead and define this as 3002.
Next, we have the payments host, which we know will be payments and the payments port which we can
check to see will be at 3001.
So let's go ahead and define that now.
So finally we can go ahead and run helm Upgrade Sleeper one more time.
And if we run Kubectl get Pods, we can see our reservation pod has finally started up.
Let's go ahead and check out the logs to see that it has started up successfully.