openshift oc使用管理员登录

  • 添加kubeconfig的环境变量
  KUBECONFIG=$(pwd)/openshift.local.config/master/admin.kubeconfig
  • oc登录指定config文件
  oc login -u system:admin -n default --config=$KUBECONFIG
  • 使用管理员权限操作
  oc your command --config=$KUBECONFIG
  • Openshift常用操作:
   - oc delete DaemonSet --all : 删除所有DammonSet
  • 查看编辑执行权
   - oc get scc
   - oc edit scc restricted
  • 项目赋权给用户
   - oadm policy add-role-to-user admin \<user> -n \<project>
  • 绑定主机
  annotations:
        scheduler.alpha.kubernetes.io/affinity: >-
          {"nodeAffinity":{"requiredDuringSchedulingIgnoredDuringExecution":{"nodeSelectorTerms":[{"matchExpressions":[{"key":"kubernetes.io/hostname","operator":"In","values":["rdchitsm"]}]}]}}} 
  • 绑定主机目录 hostPath

  • 授权集群管理员

  oc adm policy add-cluster-role-to-user cluster-admin -z test -n test

VinkDong

open to open