GithubHelp home page GithubHelp logo

devopskubernetes's Introduction

DevOps Kubernetes Project

Project Description

As a Kubernetes developer, demonstrate the usage of Volume to communicate between two Containers running in the same Pod. Check the health of the running pod by describing it with the list of events, inspecting its logs, and finally debugging its containers.

Configure Environment

Initialize Kubernetes Cluster

minikube start

Deploy Pod

Create a configuration yaml file:

vim pod.yaml

Set the following contents:

apiVersion: v1
kind: Pod
metadata:
  name: multi-container
spec: 
  terminationGracePeriodSeconds: 0
  containers:
  - name: webserver
    image: nginx:latest
    ports:
    - containerPort: 80
    volumeMounts:
    - name: html-volume
      mountPath: /usr/share/nginx/html
  - name: worker
    image: nginx:latest
    command: ["/bin/sh"]
    args: ["-c", "while true; do date > /usr/share/nginx/html/index.html; sleep 1; done"]
    volumeMounts:
    - name: html-volume
      mountPath: /usr/share/nginx/html
  volumes:
  - name: html-volume
    hostPath:
      path: /usr/share/nginx/html
      type: DirectoryOrCreate

Create the pod:

kubectl create -f pod.yaml

Forward port across kubernetes kubectl port-forward --address 0.0.0.0 pod/multi-container 1313:80 We exposed port 80 on the container (default for nginx), but the container is nested within Kubernetes. This way we can bind kubernetes to port 1313 and it will direct us to our container.

Navigate to localhost:1313/index.html in a browser, the current date should be presented. If you refresh, the time will update due to the second container editing the file in the shared volume.

Inspect the Pod

Describe the pod

kubectl describe pods multi-container

Inspect pod logs:

kubectl logs multi-container webserver

kubectl logs multi-container worker

devopskubernetes's People

Contributors

andrewevans1 avatar

Watchers

James Cloos avatar  avatar

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.