想ingress controller
为k8s创建一个。使用 nginx 入口示例来执行此操作。
按照这个创建的nginx-rc.yaml
文件:
apiVersion: v1
kind: ReplicationController
metadata:
name: nginx-ingress-controller
labels:
k8s-app: nginx-ingress-lb
spec:
replicas: 1
selector:
k8s-app: nginx-ingress-lb
template:
metadata:
labels:
k8s-app: nginx-ingress-lb
name: nginx-ingress-lb
spec:
terminationGracePeriodSeconds: 60
containers:
- image: gcr.io/google_containers/nginx-ingress-controller:0.8.3
name: nginx-ingress-lb
imagePullPolicy: Always
readinessProbe:
httpGet:
path: /healthz
port: 10254
scheme: HTTP
livenessProbe:
httpGet:
path: /healthz
port: 10254
scheme: HTTP
initialDelaySeconds: 10
timeoutSeconds: 1
# use downward API
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
ports:
- containerPort: 80
- containerPort: 443
args:
- /nginx-ingress-controller
- --default-backend-service=$(POD_NAMESPACE)/default-http-backend
- --nginx-configmap=$(POD_NAMESPACE)/nginx-ingress-controller
创建后,k8s 显示:
从控制台检查:
$ kubectl describe pod nginx-ingress-controller-5wxch
Name: nginx-ingress-controller-5wxch
Namespace: default
Node: minikube/192.168.99.100
Start Time: Fri, 17 Nov 2017 15:50:33 +0900
Labels: k8s-app=nginx-ingress-lb
name=nginx-ingress-lb
Annotations: kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicationController","namespace":"default","name":"nginx-ingress-controller","uid":"9c1aba15-cb63-11e7-9...
Status: Running
IP: 172.17.0.15
Created By: ReplicationController/nginx-ingress-controller
Controlled By: ReplicationController/nginx-ingress-controller
Containers:
nginx-ingress-lb:
Container ID: docker://9fabc8d7f74b442c35ac5f443e7f35117b183e61aa37851dfdb5847d90252672
Image: gcr.io/google_containers/nginx-ingress-controller:0.8.3
Image ID: docker-pullable://gcr.io/google_containers/nginx-ingress-controller@sha256:820c338dc22eda7ab6331001da3cccd43b1b7dcd179049d33a62ad6deaef8daf
Ports: 80/TCP, 443/TCP
Args:
/nginx-ingress-controller
--default-backend-service=$(POD_NAMESPACE)/default-http-backend
--nginx-configmap=$(POD_NAMESPACE)/nginx-ingress-controller
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Error
Exit Code: 255
Started: Fri, 17 Nov 2017 15:52:43 +0900
Finished: Fri, 17 Nov 2017 15:52:43 +0900
Ready: False
Restart Count: 4
Liveness: http-get http://:10254/healthz delay=10s timeout=1s period=10s #success=1 #failure=3
Readiness: http-get http://:10254/healthz delay=0s timeout=1s period=10s #success=1 #failure=3
Environment:
POD_NAME: nginx-ingress-controller-5wxch (v1:metadata.name)
POD_NAMESPACE: default (v1:metadata.namespace)
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-0nlh9 (ro)
Conditions:
Type Status
Initialized True
Ready False
PodScheduled True
Volumes:
default-token-0nlh9:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-0nlh9
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 3m default-scheduler Successfully assigned nginx-ingress-controller-5wxch to minikube
Normal SuccessfulMountVolume 3m kubelet, minikube MountVolume.SetUp succeeded for volume "default-token-0nlh9"
Warning Unhealthy 2m kubelet, minikube Readiness probe failed: Get http://172.17.0.15:10254/healthz: dial tcp 172.17.0.15:10254: getsockopt: connection refused
Normal Pulling 1m (x5 over 3m) kubelet, minikube pulling image "gcr.io/google_containers/nginx-ingress-controller:0.8.3"
Normal Pulled 1m (x5 over 2m) kubelet, minikube Successfully pulled image "gcr.io/google_containers/nginx-ingress-controller:0.8.3"
Normal Created 1m (x5 over 2m) kubelet, minikube Created container
Normal Started 1m (x5 over 2m) kubelet, minikube Started container
Warning BackOff 0s (x17 over 2m) kubelet, minikube Back-off restarting failed container
Warning FailedSync 0s (x17 over 2m) kubelet, minikube Error syncing pod
现在在 Mac 上使用 minikube。Kubernetes 版本是:
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.2", GitCommit:"bdaeafa71f6c7c04636251031f93464384d54963", GitTreeState:"clean", BuildDate:"2017-10-24T19:48:57Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.5", GitCommit:"17d7182a7ccbb167074be7a87f0a68bd00d58d97", GitTreeState:"clean", BuildDate:"2017-10-06T20:53:14Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
那么是什么原因呢?这个版本不支持配置文件,还是配置文件已经过时?