Code Monkey home page Code Monkey logo

sk-workshop's Introduction

Workshop

Example for Centos.

ssh centos@PUBLIC_IP

1. Install kubernetes

Install Docker

sudo yum install -y docker
sudo systemctl enable docker && sudo systemctl start docker

Install kubeadm, kubelet & kubectl

sudo bash -c 'cat > /etc/yum.repos.d/kubernetes.repo' << EOF
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
exclude=kube*
EOF
sudo setenforce 0
sudo yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
sudo systemctl enable kubelet && sudo systemctl start kubelet

Install kubernetes

sudo sysctl net.bridge.bridge-nf-call-iptables=1
sudo kubeadm init --pod-network-cidr=10.244.0.0/16 --kubernetes-version=stable-1.11

Configurate kubectl

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Check

Check components

[centos@demo ~]$ kubectl get cs
NAME                 STATUS    MESSAGE              ERROR
scheduler            Healthy   ok                   
controller-manager   Healthy   ok                   
etcd-0               Healthy   {"health": "true"}  

Check pods

[centos@demo ~]$ kubectl get po --all-namespaces
NAMESPACE     NAME                                                                    READY     STATUS    RESTARTS   AGE
kube-system   coredns-78fcdf6894-jdfsl                                                0/1       Pending   0          1m
kube-system   coredns-78fcdf6894-jrdpv                                                0/1       Pending   0          1m
kube-system   etcd-demo.eu-central-1.compute.internal                                 1/1       Running   0          1m
kube-system   kube-apiserver-demo.eu-central-1.compute.internal                       1/1       Running   0          51s
kube-system   kube-controller-manager-demo.eu-central-1.compute.internal              1/1       Running   0          1m
kube-system   kube-proxy-w8jdr                                                        1/1       Running   0          1m
kube-system   kube-scheduler-demo.eu-central-1.compute.internal                       1/1       Running   0          1m

Install Flanel

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.10.0/Documentation/kube-flannel.yml

Check pods

[centos@demo ~]$ kubectl get po --all-namespaces
NAMESPACE     NAME                                                                    READY     STATUS    RESTARTS   AGE
kube-system   canal-87jrb                                                             3/3       Running   0          6m
kube-system   coredns-78fcdf6894-jdfsl                                                1/1       Running   0          13m
kube-system   coredns-78fcdf6894-jrdpv                                                1/1       Running   1          13m
kube-system   etcd-demo.eu-central-1.compute.internal                                 1/1       Running   0          13m
kube-system   kube-apiserver-demo.eu-central-1.compute.internal                       1/1       Running   0          12m
kube-system   kube-controller-manager-demo.eu-central-1.compute.internal              1/1       Running   0          13m
kube-system   kube-proxy-w8jdr                                                        1/1       Running   0          13m
kube-system   kube-scheduler-demo.eu-central-1.compute.internal                       1/1       Running   0          13m

Master Isolation

kubectl taint nodes --all node-role.kubernetes.io/master-

3. Deploy simple app "Hello world"

Create deployment

kubectl create -f https://raw.githubusercontent.com/containerum/sk-workshop/master/hello/hello-deploy.yaml

Create service

kubectl create -f https://raw.githubusercontent.com/containerum/sk-workshop/master/hello/hello-service.yaml

Get Service

kubectl get svc

NAME         TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
hw           LoadBalancer   10.103.70.246   <pending>     5000:30180/TCP   16s
kubernetes   ClusterIP      10.96.0.1       <none>        443/TCP          21m

Go to browser

https://ip:30180

where ip is IP of your VM

4. Deploy Containerum

Deploy Helm

curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > get_helm.sh
chmod 700 get_helm.sh
./get_helm.sh
kubectl create -f https://raw.githubusercontent.com/containerum/sk-workshop/master/helm/rbac.yaml
helm init --service-account tiller

Check:

helm list

Deploy Ingress Controller

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/mandatory.yaml
bash -c 'cat > ingress.yaml' << EOF
apiVersion: v1
kind: Service
metadata:
  name: ingress-nginx
  namespace: ingress-nginx
spec:
  ports:
  - name: http
    port: 80
    targetPort: 80
    protocol: TCP
  - name: https
    port: 443
    targetPort: 443
    protocol: TCP
  selector:
    app.kubernetes.io/name: ingress-nginx
  externalIPs:
  - %EXTERNAL IP%
EOF
kubectl apply -f ingress.yaml

Check:

kubectl get pods --namespace=ingress
NAME                                                         READY     STATUS    RESTARTS   AGE
musty-bobcat-nginx-ingress-controller-659565fbc6-zx8fj       1/1       Running   0          46s
musty-bobcat-nginx-ingress-default-backend-c57dc4765-d72hp   1/1       Running   0          46s

Deploy Containerum

helm repo add containerum https://charts.containerum.io
helm repo update
helm install containerum/containerum
kubectl label node $HOSTNAME role=slave

5. Deploy WP+MySQL

This app uses Volumes

Create PersistentVolume

kubectl create -f https://raw.githubusercontent.com/containerum/sk-workshop/master/wp/pv.yaml
[centos@demo ~]$ kubectl get pv
NAME       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM     STORAGECLASS   REASON    AGE
mysql-pv   10Gi       RWO            Retain           Available             manual                   7s
wp-pv      10Gi       RWO            Retain           Available             manual                   7s

Create PersistentVolumeClaim

kubectl create -f https://raw.githubusercontent.com/containerum/sk-workshop/master/wp/pvc.yaml
[centos@demo ~]$ kubectl get pvc
NAME        STATUS    VOLUME     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
mysql-pvc   Bound     mysql-pv   10Gi       RWO            manual         7s
wp-pvc      Bound     wp-pv      10Gi       RWO            manual         7s

Create Secret for MySQL Password

kubectl create secret generic mysql-pass --from-literal=password=strongpassword
[centos@demo ~]$ kubectl get secrets
NAME                  TYPE                                  DATA      AGE
default-token-546hk   kubernetes.io/service-account-token   3         39m
mysql-pass            Opaque                                1         12s

Deploy MySQL

kubectl create -f https://raw.githubusercontent.com/containerum/sk-workshop/master/wp/mysql.yaml

Deploy WP

kubectl create -f https://raw.githubusercontent.com/containerum/sk-workshop/master/wp/wp.yaml

sk-workshop's People

Contributors

kfeofantov avatar

Stargazers

Viktor Sidorenko avatar Bruno Gomes avatar YURI TRUKHIN avatar Vyatcheslav Mogilevsky avatar Terskikh Maria avatar

Watchers

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