Coder Social home page Coder Social logo

kubernetes-rails-example's Introduction

Rails โ†’ Kubernetes, using GitHub Actions

Rails app for experiments with deployment to Kubernetes cluster.

If you are going to use it for some purpose, please replace mgrigoriev/kubernetes-rails-example with a name of your docker image in all configuration files.

Configuration files

K8s cluster setup

cd ~/.kube

# Add "do.yaml" config to existing "config" file
export KUBECONFIG=config:do.yaml

# See contexts for all clusters
kubectl config get-contexts

# Set current context
kubectl config use-context <context-name>

# Check if we are in the right context
kubectl get nodes

# Apply manifests
kubectl apply -R -f /path/to/app/.k8s/

# Create secret for pulling image from Docker registry
kubectl create secret docker-registry regcred --docker-server=registry-server> \
                                              --docker-username=<username> \
                                              --docker-password=<password> \
                                              --docker-email=<email>

# Create secrets for access to external database and redis server
kubectl create secret generic env --from-literal=DATABASE_URL=postgres://<user>:<pass>@<ip>:5432/<dbname> \
                                  --from-literal=REDIS_URL=redis://<ip>:6379/0

GitHub setup

Create secrets required for GitHub Actions:

  • DOCKERHUB_USERNAME
  • DOCKERHUB_TOKEN
  • KUBE_CONFIG_DATA

Run this command to get a value for KUBE_CONFIG_DATA:

cat $HOME/.kube/<cluster-config> | base64

Notes for Minikube

  1. Use host.minikube.internal instead of ip address in DATABASE_URL and REDIS_URL when Postgres and redis are running on a host machine.
  1. Minikube requires manual action for load balancer service. After applying k8s manifests, run this command:
    minikube service kubernetes-rails-example-load-balancer -n <your-namespace>
    

Useful links

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.