K8s-创建应用

ps:deployment 跟rc 功能一样

node3、node4也要导入
[root@linux-node4 k8s]# docker load < kubernetes-dashboard-amd64-v1.5.1.tar
[root@linux-node4 k8s]# docker load < pause-amd64-3.0.tar

先拿nginx做试验
[root@linux-node3 k8s]# vim nginx-deployment.yaml
[root@linux-node3 k8s]# kubectl create -f nginx-deployment.yaml
deployment “nginx-deployment” created

[root@linux-node3 k8s]# kubectl get pods 成功
NAME READY STATUS RESTARTS AGE
nginx-deployment-1247087418-b9939 1/1 Running 5 5m
nginx-deployment-1247087418-v3ntw 1/1 Running 4 5m

[root@linux-node3 /]# kubectl get pods -o yaml -L app=nginx | grep podIP 查看上面3台IP,不过没有意义,可能重启后就还掉IP了

这里安装碰到了问题
1.由于网络模式问题 需要在vim /etc/docker/daemon.json 添加
“default-ipc-mode”: “shareable” —2台都要改
2.sysctl -w vm.max_map_count=262144 系统参数要改

为了固定ip所创建
[root@linux-node3 k8s]# kubectl create -f nginx-service.yaml

root@linux-node3 k8s]# kubectl get service
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes 10.1.0.1 443/TCP 2d
nginx-demo 10.1.12.94 80/TCP 16s

安装个dashboard
[root@linux-node3 k8s]# vim kubernetes-dashboard.yaml

# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Configuration to deploy release version of the Dashboard UI.
#
# Example usage: kubectl create -f <this_file>

kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  labels:
    app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kube-system
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kubernetes-dashboard
  template:
    metadata:
      labels:
        app: kubernetes-dashboard
      # Comment the following annotation if Dashboard must not be deployed on master
      annotations:
        scheduler.alpha.kubernetes.io/tolerations: |
          [
            {
              "key": "dedicated",
              "operator": "Equal",
              "value": "master",
              "effect": "NoSchedule"
            }
          ]
    spec:
      containers:
      - name: kubernetes-dashboard
        image: gcr.io/google_containers/kubernetes-dashboard-amd64:v1.5.1
        ports:
        - containerPort: 9090
          protocol: TCP
        args:
          # Uncomment the following line to manually specify Kubernetes API server Host
          # If not specified, Dashboard will attempt to auto discover the API server and connect
          # to it. Uncomment only if the default does not work.
          - --apiserver-host=http://10.0.0.17:8080
        livenessProbe:
          httpGet:
            path: /
            port: 9090
          initialDelaySeconds: 30
          timeoutSeconds: 30
---
kind: Service
apiVersion: v1
metadata:
  labels:
    app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kube-system
spec:
  type: NodePort
  ports:
  - port: 80
    targetPort: 9090
  selector:
    app: kubernetes-dashboard
-- INSERT --                                                                          50,12         Bot
    metadata:
      labels:
        app: kubernetes-dashboard
      # Comment the following annotation if Dashboard must not be deployed on master
      annotations:
        scheduler.alpha.kubernetes.io/tolerations: |
          [
            {
              "key": "dedicated",
              "operator": "Equal",
              "value": "master",
              "effect": "NoSchedule"
            }
          ]
    spec:
      containers:
      - name: kubernetes-dashboard
        image: gcr.io/google_containers/kubernetes-dashboard-amd64:v1.5.1
        ports:
        - containerPort: 9090
          protocol: TCP
        args:
          # Uncomment the following line to manually specify Kubernetes API server Host
          # If not specified, Dashboard will attempt to auto discover the API server and connect
          # to it. Uncomment only if the default does not work.
          - --apiserver-host=http://10.0.0.17:8080
        livenessProbe:
          httpGet:
            path: /
            port: 9090
          initialDelaySeconds: 30
          timeoutSeconds: 30
---
kind: Service
apiVersion: v1
metadata:
  labels:
    app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kube-system
spec:
  type: NodePort
  ports:
  - port: 80
    targetPort: 9090
  selector:
    app: kubernetes-dashboard

[root@linux-node3 k8s]# kubectl create -f kubernetes-dashboard.yaml
[root@linux-node3 k8s]# kubectl get deployment --namespace=kube-system
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
kubernetes-dashboard 1 1 1 1 53s

[root@linux-node3 k8s]# kubectl logs kubernetes-dashboard-2892427143-vbrsk --namespace=kube-system —看单个容器日志的命令

在这里插入图片描述
[root@linux-node3 k8s]# kubectl logs kubernetes-dashboard-2892427143-vbrsk --namespace=kube-system

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值