Followers

Kubernetes Service Assignment

1. Create a deployment for a webapp (ramansharma95/webapp) on port 80 (replica =1) 2. Create a deployment for a dbapp (ramansharma95/mysql) ...

1. Create a deployment for a webapp (ramansharma95/webapp) on port 80 (replica =1)

2. Create a deployment for a dbapp (ramansharma95/mysql) on port 3306 (replica=1)

3. Create a NodePort service(name of service webservice) for webapp and nodeport value is 31000.

4. Create a ClusterIP service(name of service db) for dbapp.

5. The webservice should communicate to db. (In webapp there is a connection string which points to db) 


COMMENTS

BLOGGER: 4
  1. 1. vi deploy-webapp.yaml
    apiVersion: apps/v1
    kind: Deployment
    metadata:
    name: webapp-deployment
    labels:
    app: webapp
    spec:
    replicas: 1
    selector:
    matchLabels:
    app: webapp
    template:
    metadata:
    labels:
    app: webapp
    spec:
    containers:
    - name: webapp-container
    image: ramansharma95/webapp
    ports:
    - containerPort: 80
    2. vi deploy-mysql.yaml
    apiVersion: apps/v1
    kind: Deployment
    metadata:
    name: mysql-deployment
    labels:
    app: mysql
    spec:
    replicas: 1
    selector:
    matchLabels:
    app: mysql
    template:
    metadata:
    labels:
    app: mysql
    spec:
    containers:
    - name: mysql-container
    image: ramansharma95/mysql
    ports:
    - containerPort: 3306
    3. vi np-webapp.yaml
    apiVersion: v1
    kind: Service
    metadata:
    name: webservice
    labels:
    app: webapp
    spec:
    selector:
    app: webapp
    type: NodePort
    ports:
    - nodePort: 31000
    port: 80
    targetPort: 80
    4. vi np-mysql.yaml
    apiVersion: v1
    kind: Service
    metadata:
    name: db
    labels:
    app: mysql
    spec:
    selector:
    app: mysql
    type: ClusterIP
    ports:
    - port: 3306
    targetPort: 3306
    5. http://NODE-IP:NODEPORT on browser
    able to access employee registration form
    unable to add record, recall docker networking tutorial
    access db container
    kubectl exec -it <> bash
    access mysql
    mysql -uroot -pwhizlabs
    create database company;
    show databases;
    database is reflected
    use company;
    create table employee (name varchar(30), mobile varchar(30));
    try adding records on webapp
    Record added successfully
    check records in db
    select * from employee;
    records are reflected.
    Done

    ReplyDelete
  2. ken
    kubectl run dbapp --image=ramansharma95/mysql:latest --port=3306
    kubectl run webapp --image=ramansharma95/webapp:latest --port=80

    ReplyDelete
  3. 1. Create a deployment for a webapp (ramansharma95/webapp) on port 80 (replica =1)
    -> vi webapp.yml
    apiVersion: apps/v1
    kind: Deployment
    metadata:
    name: webapp-deploy
    labels:
    app: webapp-app
    spec:
    replicas: 1
    template:
    metadata:
    labels:
    app: webapp-app
    spec:
    containers:
    - name: webapp-container
    image: ramansharma95/webapp
    ports:
    - containerPort: 80
    selector:
    matchLabels:
    app: webapp-app

    -> kubectl create -f webapp.yml
    -> kubectl get po -o wide (Running)

    2. Create a deployment for a dbapp (ramansharma95/mysql) on port 3306 (replica=1)
    -> cp webapp.yml dbapp.yml
    -> vi dbapp.yml
    apiVersion: apps/v1
    kind: Deployment
    metadata:
    name: dbapp-deploy
    labels:
    app: dbapp-app
    spec:
    replicas: 1
    template:
    metadata:
    labels:
    app: dbapp-app
    spec:
    containers:
    - name: dbapp-container
    image: ramansharma95/mysql
    ports:
    - containerPort: 3306
    selector:
    matchLabels:
    app: dbapp-app

    -> kubectl create -f dbapp.yml
    -> kubectl get po -o wide (Running)

    3. Create a NodePort service(name of service webservice) for webapp and nodeport value is 31000.
    -> vi webservice.yml
    apiVersion: v1
    kind: Service
    metadata:
    name: webservice
    labels:
    app: web-app
    spec:
    selector:
    app: web-app
    type: NodePort
    ports:
    - nodePort: 31000
    port: 31000
    targetPort: 80

    -> kubectl create -f webservice.yml
    -> kubectl get svc (running)

    4. Create a ClusterIP service(name of service db) for dbapp.
    -> vi dbservice.yml
    apiVersion: v1
    kind: Service
    metadata:
    name: dbservice
    labels:
    app: db-app
    spec:
    selector:
    app: db-app
    type: ClusterIP
    ports:
    - protocol: TCP
    port: 3306
    targetPort: 80

    -> kubectl create -f dbservice.yml
    -> kubectl get svc (running)

    5. The webservice should communicate to db. (In webapp there is a connection string which points to db) 
    -> kubectl describe svc webservice

    ReplyDelete
  4. 1. Create a deployment for a webapp (ramansharma95/webapp) on port 80 (replica =1)

    vi webapp.yaml

    apiVersion: apps/v1
    kind: Deployment
    metadata:
    name: webapp-deployment
    labels:
    app: web-app
    spec:
    replicas: 1
    template:
    metadata:
    labels:
    app: web-app
    spec:
    containers:
    - name: webapp
    image: ramansharma95/webapp
    ports:
    - containerPort: 80
    selector:
    matchLabels:
    app: web-app



    2. Create a deployment for a dbapp (ramansharma95/mysql) on port 3306 (replica=1)

    vi dbapp.yaml

    apiVersion: apps/v1
    kind: Deployment
    metadata:
    name: dbapp
    labels:
    app: mysql
    spec:
    replicas: 1
    template:
    metadata:
    labels:
    app: mysql
    spec:
    containers:
    - name: dbapp
    image: ramansharma95/mysql
    ports:
    - containerPort: 3306
    selector:
    matchLabels:
    app: mysql


    3. Create a NodePort service(name of service webservice) for webapp and nodeport value is 31000.

    vi webservice.yaml

    apiVersion: v1
    kind: Service
    metadata:
    name: webservice
    labels:
    app: nginx-app
    spec:
    selector:
    app: nginx-app
    type: NodePort
    ports:
    - nodePort: 31000
    port: 80
    targetPort: 80

    kubectl create -f webservice.yaml
    kubectl get svc

    4. Create a ClusterIP service(name of service db) for dbapp.

    vi db.yaml

    apiVersion: v1
    kind: Service
    metadata:
    name: db
    labels:
    app: mysql
    spec:
    selector:
    app: mysql
    type: ClusterIP
    ports:
    - port: 3306
    targetPort: 3306


    kubectl create -f db.yaml
    kubectl get svc

    5. The webservice should communicate to db. (In webapp there is a connection string which points to db)

    localhost:31000 (can connect to webserver)

    kubectl exec -it dbapp-6cbcc8bffb-xf2rw bash

    mysql -uroot -pwhizlabs

    Create a database company

    show databases;

    create database company;

    show databases;

    use company;

    create table employee ( name varchar(30), mobile varchar(30));

    select * from employee

    ReplyDelete

Name

Ansible,6,AWS,1,Azure DevOps,1,Containerization with docker,2,DevOps,2,Docker Quiz,1,Docker Swarm,1,DockerCompose,1,ELK,2,git,2,git quiz,1,Git Worksheet,1,ITIL,1,ITSM,1,Jira,3,Kubernetes,1,Kubernetes Quiz,5,SAST DAST Security Testing,1,SDLC Quiz,5,SonarQube,3,Splunk,2,vagrant kubernetes,1,YAML Basics,1,
ltr
item
DevOpsWorld: Kubernetes Service Assignment
Kubernetes Service Assignment
DevOpsWorld
https://www.devopsworld.co.in/2022/03/kubernetes-service-assignment.html
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/2022/03/kubernetes-service-assignment.html
true
5997357714110665304
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content