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-nod
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)