Kubernetes学习笔记(六):Namespace
mysql.connect("db-service")
mysql.connect("db-service.dev.svc.cluster.local")
- cluster.local : domain
- svc : sub domain for service
- dev : Namespace
- db-service : Service Name
kubectl get pods --namespace=kube-system
确保在dev Namespace中创建的pod
kubectl create -f pod-definition.yml --namespace=dev- 在yaml文件中,指定
metadata.namespace=dev
namespace-dev.yml
apiVersion: v1
kind: Namespace
metadata:
name: dev
设置永久切换Namespace
kubectl config set-context $(kubectl config current-context) --namespace=dev
查看所有Namespace中的pods:kubectl get pods --all-namespaces,-Ashort for --all-namespaces
设置Resource Quota,Compute-quota.yaml:
apiVersion: v1
kind: ResourceQuota
metadata:
name: compute-quota
namespace: dev
spec:
hard:
pods: "10"
requests.cpu: "4"
requests.memory: 5Gi
limits.cpu: "10"
limits.memory: 10Gi
kubectl run redis --image=redis -n=finance其中-nshort for --namespace

浙公网安备 33010602011771号