Followers

Kubernetes Namespaces

       Kubernetes supports multiple virtual clusters backed by the same physical cluster. These virtual clusters are called namespaces.

       Namespaces are intended for use in environments with many users spread across multiple teams, or projects.

       Namespaces provide a scope for names. Names of resources need to be unique within a namespace, but not across namespaces. Namespaces can not be nested inside one another and each Kubernetes resource can only be in one namespace.

       Namespaces are a way to divide cluster resources between multiple users.

       It is not necessary to use multiple namespaces just to separate slightly different resources, such as different versions of the same software: use labels to distinguish resources within the same namespace.

 


Create Namespace
 


       kubectl create namespace demo1

       kubectl get namespace

       kubectl run nginx-pod --image=nginx --namespace=demo1

       kubectl get pods –namespace demo1

       kubectl delete pod nginx-pod --namespace demo1

KubeConfig file

       Use kubeconfig files to organize information about clusters, users, namespaces, and authentication mechanisms. The kubectl command-line tool uses kubeconfig files to find the information it needs to choose a cluster and communicate with the API server of a cluster.

 KubeContext

       A context element in a kubeconfig file is used to group access parameters under a convenient name. Each context has three parameters: cluster, namespace, and user. By default, the kubectl command-line tool uses parameters from the current context to communicate with the cluster.

 

Create a Pod in dev namespace

apiVersion: v1
kind: Pod
metadata:
        name: pod2
        namespace: dev
spec:
   containers:
     - name: c1
       image: nginx


Assignment

Context and Namespaces


1. Create a dev ns and create a pod called poddev in dev ns

2. Create a prod ns and create a pod called podprod in prod ns

3. View all the pods from default ns

4. Create 2 context devcontext(dev env) and prodcontext(prod env) in config using command

5. Switch to dev env and list all the pods

6. Create a deployment uder dev ns and list all the deployments and pods

7. Switch to prod env and list all the pods

8. Create a deployment under prod ns and list all the deployments and pods

9, Switch back to default ns context

10 delete prodcontext and devContext


Dashboard

COMMENTS

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,Jira,1,Kubernetes,1,Kubernetes Quiz,5,SAST DAST Security Testing,1,SonarQube,3,Splunk,2,vagrant kubernetes,1,YAML Basics,1,
ltr
static_page
DevOpsWorld: Kubernetes Namespaces
Kubernetes Namespaces
DevOpsWorld
https://www.devopsworld.co.in/p/kubernetes-namespaces.html
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/p/kubernetes-namespaces.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