Skip to content

Infrastructure

maxmwang edited this page Nov 13, 2024 · 14 revisions

Infrastructure

Onboarding

The production website is hosted on a remote machine supplied by the OCF. Connecting to this machine requires SSH.

This guide assumes basic experience with SSH.

Warning

Running commands in the hozer machine can break production! Continue with caution.

  1. Copy your SSH key to the hozer machine's authorized_keys file:

    ssh-copy-id [email protected]
    

    The SSH password can be found in the pinned messages of the #backend staff channel in discord.

    Please add an identifying comment to your public key! For example, your Berkeley email suffices.

  2. (Optional) Add hozer-51 to your ~/.ssh/config file:

    # Begin Berkeleytime hozer config
    Host hozer-??
        HostName %h.ocf.berkeley.edu
        User root
    # End Berkeleytime hozer config

    Now, you can quickly SSH into the remote machine from your terminal:

    ssh hozer-51
    # as opposed to [email protected]

Architecture

Berkeleytime uses a microservices architecture, like many larger projects and products. A microservice architecture provides many benefits in scaling, fault-tolerance, and flexibility that a monolith architecture lacks. With these advantages comes with disadvantages, the largest being the additional complexity.

Here is a diagram describing a simplified version of the system architecture. Berkeleytime System Architectural Design

Kubernetes & Helm

Kubernetes is a container orchestrator, a fundamental piece of our microservice architecture. It is a complex system with many different components. Fortunately, the documentation is decently well-written. The concepts page is a good place to start.

Helm is a package manager for Kubernetes. It allows us to build Kubernetes resources that are easily configurable and reusable. For simplicity, we try to keep all of our Kubernetes resources defined with helm, as opposed to some being defined with raw resource definitions and some with helm charts.

Tip

On hozer-51, k is an alias for kubectl and h is an alias for helm.

Important

The default namespace has been set as bt.

Here are a few useful commands:

Command Description
k get pods View all running pods.
k get pods -l env=[dev|stage|prod] View all running pods in a specified environment.
k logs [pod name] View logs of a pod. You can get a pod's name with k get pods.
k describe pod [pod name] View a description of a pod. Useful for when pod is failing to startup, thus not showing any logs.
k exec -it [pod name] -- [command] Execute a command inside a pod. The command can be bash, which will start a shell inside the pod and allow for more commands.
k get deploy View all running deployments.
k get deploy -l env=[dev|stage|prod] View all running deployments in a specified environment.
k rollout restart deploy/[deploy name] Manually restart a deployment.
h list List helm chart installations.