Home Explore Blog CI



docker

2nd chunk of `content/guides/ruby/deploy.md`
4d517ed84f2cb5508a8d9e6ed0017c7cdc4df3b2faed698d0000000100000826
  described under `template`, has just one container in it. The
  container is created from the image built by GitHub Actions in [Configure CI/CD for
  your Ruby on Rails application](configure-github-actions.md).
- A NodePort service, which will route traffic from port 30001 on your host to
  port 8001 inside the pods it routes to, allowing you to reach your app
  from the network.

To learn more about Kubernetes objects, see the [Kubernetes documentation](https://kubernetes.io/docs/home/).

## Deploy and check your application

1. In a terminal, navigate to `docker-ruby-on-rails` and deploy your application to
   Kubernetes.

   ```console
   $ kubectl apply -f docker-ruby-on-rails-kubernetes.yaml
   ```

   You should see output that looks like the following, indicating your Kubernetes objects were created successfully.

   ```shell
   deployment.apps/docker-ruby-on-rails-demo created
   service/docker-ruby-on-rails-demo created
   ```

2. Make sure everything worked by listing your deployments.

   ```console
   $ kubectl get deployments
   ```

   Your deployment should be listed as follows:

   ```shell
   NAME                       READY   UP-TO-DATE   AVAILABLE   AGE
   docker-ruby-on-rails-demo  1/1     1            1           15s
   ```

   This indicates all one of the pods you asked for in your YAML are up and running. Do the same check for your services.

   ```console
   $ kubectl get services
   ```

   You should get output like the following.

   ```shell
   NAME                        TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
   kubernetes                  ClusterIP   10.96.0.1       <none>        443/TCP          23h
   docker-ruby-on-rails-demo   NodePort    10.99.128.230   <none>        3000:30001/TCP   75s
   ```

   In addition to the default `kubernetes` service, you can see your `docker-ruby-on-rails-demo` service, accepting traffic on port 30001/TCP.

3. To create and migrate the database in a Ruby on Rails application running on Kubernetes, you need to follow these steps.

   **Get the Current Pods**:

Title: Deploying and Verifying the Ruby on Rails Application on Kubernetes
Summary
This section details how to deploy the Ruby on Rails application to Kubernetes using the `kubectl apply` command and the created YAML file. It then guides you through verifying the successful deployment by listing the deployments and services using `kubectl get deployments` and `kubectl get services`, ensuring the pod is running and the service is accepting traffic on the specified port. Finally, it introduces the need to migrate the database in a Ruby on Rails application running on Kubernetes.