All Projects → paulbouwer → Hello Kubernetes

paulbouwer / Hello Kubernetes

Licence: mit
Provides a demo app to deploy to a Kubernetes cluster. It displays a message, the name of the pod and details of the node it's deployed to.

Projects that are alternatives of or similar to Hello Kubernetes

Phphub Ios
PHPHub for iOS is the universal iPhone and iPad application for PHPHub
Stars: ✭ 1,223 (+533.68%)
Mutual labels:  demo-app
Searchviewsample
Sample app for Android SearchView with circular reveal animation like whatsapp
Stars: ✭ 125 (-35.23%)
Mutual labels:  demo-app
Weapp demos
持续更新中的微信小程序和小游戏的源码案例库。目前涵盖了120多个微信小程序或小游戏。
Stars: ✭ 2,466 (+1177.72%)
Mutual labels:  demo-app
Circleci Demo Python Django
Example Django application running on CircleCI
Stars: ✭ 100 (-48.19%)
Mutual labels:  demo-app
Dwwxpay
微信支付/订单查询
Stars: ✭ 122 (-36.79%)
Mutual labels:  demo-app
Fullscreencamera
A Full Screen Camera App written in Swift
Stars: ✭ 131 (-32.12%)
Mutual labels:  demo-app
Multiselectrecyclerview
Multi select like WhatsApp in Android
Stars: ✭ 66 (-65.8%)
Mutual labels:  demo-app
Chatify Demo
Chatify Laravel Package Demo application
Stars: ✭ 189 (-2.07%)
Mutual labels:  demo-app
Thorui Uniapp
ThorUI组件库,轻量、简洁的移动端组件库。组件文档地址:https://thorui.cn/doc/ 。 最近更新时间:2021-10-01
Stars: ✭ 1,842 (+854.4%)
Mutual labels:  demo-app
Redux React Navigation Demos
React-Native + Redux + Redux-Persist + React Navigation ( Authentication Flow with Redux demos)
Stars: ✭ 151 (-21.76%)
Mutual labels:  demo-app
Cakephp Realworld Example App
Stars: ✭ 103 (-46.63%)
Mutual labels:  demo-app
Cameraxdemo
A sample camera app with CameraX API from Android Jetpack
Stars: ✭ 112 (-41.97%)
Mutual labels:  demo-app
Swift project
原OC项目用swift实现,纯swift项目,可作为学习swift的demo,包含多个自定义控件,并且进行封装网络请求库,结构清晰。
Stars: ✭ 133 (-31.09%)
Mutual labels:  demo-app
Recyclerviewdemo
Demo showing the basics to advanced use cases of Android RecyclerView
Stars: ✭ 92 (-52.33%)
Mutual labels:  demo-app
Textdetection
Vision Framework Demo on Text Detection
Stars: ✭ 173 (-10.36%)
Mutual labels:  demo-app
Dotnet Template Onion
Onion Architecture with .NET 5/.NET Core and CQRS/Event Sourcing following a DDD approach
Stars: ✭ 70 (-63.73%)
Mutual labels:  demo-app
Todayx
🌈Flutter App:🎊「今日份的X」(每天推荐一个:图片、诗歌、名言、音乐、乐评、高等数学、两种配色、化学方程式、Github Repo、知乎问题、文章)
Stars: ✭ 128 (-33.68%)
Mutual labels:  demo-app
Openui5 Sample App
OpenUI5 Sample App
Stars: ✭ 193 (+0%)
Mutual labels:  demo-app
Estmusicplayer
An elegant and simple iOS music player.
Stars: ✭ 2,165 (+1021.76%)
Mutual labels:  demo-app
Realm Draw
The official Realm Draw app used in promotional videos
Stars: ✭ 150 (-22.28%)
Mutual labels:  demo-app

Hello Kubernetes!

Docker Image Version (latest by date) Docker Image Size (latest by date) Docker Pulls

This container image can be deployed on a Kubernetes cluster. When accessed via a web browser on port 8080, it will display:

  • a default Hello world! message
  • the pod name
  • node os information

Hello world! from the hello-kubernetes image

The default "Hello world!" message displayed can be overridden using the MESSAGE environment variable. The default port of 8080 can be overriden using the PORT environment variable.

Deploy

Standard Configuration

Deploy to your Kubernetes cluster using the hello-kubernetes.yaml, which contains definitions for the service and deployment objects:

# hello-kubernetes.yaml
apiVersion: v1
kind: Service
metadata:
  name: hello-kubernetes
spec:
  type: LoadBalancer
  ports:
  - port: 80
    targetPort: 8080
  selector:
    app: hello-kubernetes
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-kubernetes
spec:
  replicas: 3
  selector:
    matchLabels:
      app: hello-kubernetes
  template:
    metadata:
      labels:
        app: hello-kubernetes
    spec:
      containers:
      - name: hello-kubernetes
        image: paulbouwer/hello-kubernetes:1.9
        ports:
        - containerPort: 8080
$ kubectl apply -f yaml/hello-kubernetes.yaml

This will display a Hello world! message when you hit the service endpoint in a browser. You can get the service endpoint ip address by executing the following command and grabbing the returned external ip address value:

$ kubectl get service hello-kubernetes

Customise Message

You can customise the message displayed by the hello-kubernetes container. Deploy using the hello-kubernetes.custom-message.yaml, which contains definitions for the service and deployment objects.

In the definition for the deployment, add an env variable with the name of MESSAGE. The value you provide will be displayed as the custom message.

# hello-kubernetes.custom-message.yaml
apiVersion: v1
kind: Service
metadata:
  name: hello-kubernetes-custom
spec:
  type: LoadBalancer
  ports:
  - port: 80
    targetPort: 8080
  selector:
    app: hello-kubernetes-custom
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-kubernetes-custom
spec:
  replicas: 3
  selector:
    matchLabels:
      app: hello-kubernetes-custom
  template:
    metadata:
      labels:
        app: hello-kubernetes-custom
    spec:
      containers:
      - name: hello-kubernetes
        image: paulbouwer/hello-kubernetes:1.9
        ports:
        - containerPort: 8080
        env:
        - name: MESSAGE
          value: I just deployed this on Kubernetes!
$ kubectl apply -f yaml/hello-kubernetes.custom-message.yaml

Specify Custom Port

By default, the hello-kubernetes app listens on port 8080. If you have a requirement for the app to listen on another port, you can specify the port via an env variable with the name of PORT. Remember to also update the containers.ports.containerPort value to match.

Here is an example:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-kubernetes-custom
spec:
  replicas: 3
  selector:
    matchLabels:
      app: hello-kubernetes-custom
  template:
    metadata:
      labels:
        app: hello-kubernetes-custom
    spec:
      containers:
      - name: hello-kubernetes
        image: paulbouwer/hello-kubernetes:1.9
        ports:
        - containerPort: 80
        env:
        - name: PORT
          value: "80"

Cutomize URL context path

If you have an ingress that routes to a custom context path then you can customize the URL context path. The css files and the images will be loaded properly in that case.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-kubernetes-custom
spec:
  replicas: 3
  selector:
    matchLabels:
      app: hello-kubernetes-custom
  template:
    metadata:
      labels:
        app: hello-kubernetes-custom
    spec:
      containers:
      - name: hello-kubernetes
        image: paulbouwer/hello-kubernetes:1.9
        ports:
        - containerPort: 8080
        env:
        - name: MESSAGE
          value: I just deployed this on Kubernetes!
        - name: CONTEXT_PATH
          value: "/api/v1/hello-kubernetes/"

Build Container Image

If you'd like to build the image yourself, then you can do so as follows. The build-arg parameters provides metadata as defined in OCI image spec annotations.

Bash

$ docker build --no-cache --build-arg IMAGE_VERSION="1.9" --build-arg IMAGE_CREATE_DATE="`date -u +"%Y-%m-%dT%H:%M:%SZ"`" --build-arg IMAGE_SOURCE_REVISION="`git rev-parse HEAD`" -f Dockerfile -t "hello-kubernetes:1.9" app

Powershell

PS> docker build --no-cache --build-arg IMAGE_VERSION="1.9" --build-arg IMAGE_CREATE_DATE="$(Get-Date((Get-Date).ToUniversalTime()) -UFormat '%Y-%m-%dT%H:%M:%SZ')" --build-arg IMAGE_SOURCE_REVISION="$(git rev-parse HEAD)" -f Dockerfile -t "hello-kubernetes:1.9" app

Develop Application

If you have VS Code and the Visual Studio Code Remote - Containers extension installed, the .devcontainer folder will be used to build a container based node.js 13 development environment.

Port 8080 has been configured to be forwarded to your host. If you run npm start in the app folder in the VS Code Remote Containers terminal, you will be able to access the website on http://localhost:8080. You can change the port in the .devcontainer\devcontainer.json file under the appPort key.

See here for more details on working with this setup.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].