Git Product home page Git Product logo

k8s-test-app's Introduction

k8s-test-app

study for kubernetes

Before start

Run minikube

start

$ minikube start

check

$ minikube status
host: Running
kubelet: Running
apiserver: Running
kubectl: Correctly Configured: pointing to minikube-vm at 192.168.99.100

set minikube docker-env

$ eval $(minikube docker-env)

Build docker

$ docker build -t simple-app:0.0.2 .

Create deployment

$ kubectl create -f k8s/minikube/app-deployment.yml
$ kubectl create -f k8s/minikube/db-deployment.yml

check

$ kubectl get po
NAME                   READY   STATUS    RESTARTS   AGE
app-57c65b4fcc-kndxk   1/1     Running   0          5m56s
db-96cc996d4-wbtqk     1/1     Running   0          45m

$ kubectl get deployment
NAME   READY   UP-TO-DATE   AVAILABLE   AGE
app    1/1     1            1           8m9s
db     1/1     1            1           48m

Create service

$ kubectl create -f k8s/minikube/app-service.yml
$ kubectl create -f k8s/minikube/db-service.yml

check

$ kubectl get service
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
app          NodePort    10.110.33.109    <none>        80:30765/TCP   70m
db           ClusterIP   10.106.253.125   <none>        3306/TCP       45m
kubernetes   ClusterIP   10.96.0.1        <none>        443/TCP        36h

Set DB data

$ kubectl exec -it db-xxxxxxxxxx-xxxxx /bin/sh`
$ mysql -uroot -ppassword
$ CREATE DATABASE app;
$ USE app;
$ CREATE TABLE user (id int, name varchar(10));
$ INSERT INTO user (id, name) VALUES (1, "hoge");
$ INSERT INTO user (id, name) VALUES (2, "fuga");

Access Server

get minikube service url

$ minikube service app --url

access app server (change ip:port what you get above)

$ curl http://192.168.99.100:30765/hello
1: hoge
2: fuga

k8s-test-app's People

Contributors

myoan avatar

Watchers

 avatar James Cloos 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.