Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.77 KB | None | 0 0
  1. ## stop the cluster version operator
  2.  
  3. ```
  4. [core@ip-10-0-7-170 ~]$ oc get deployments --namespace=openshift-cluster-version
  5. [core@ip-10-0-7-170 ~]$ oc scale deployment cluster-version-operator --replicas=0 --namespace=openshift-cluster-version
  6. ```
  7.  
  8. ## Edit our deployment
  9.  
  10. Check out the current deployment...
  11.  
  12. ```
  13. [core@ip-10-0-7-170 ~]$ oc get pods -o wide --namespace=openshift-network-operator
  14. NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE
  15. network-operator-797d9cd447-4b4wz 1/1 Running 0 4h20m 10.0.132.215 ip-10-0-132-215.us-west-2.compute.internal <none>
  16. ```
  17.  
  18. Edit that deployment...
  19.  
  20. ```
  21. [core@ip-10-0-7-170 ~]$ oc edit deployment --namespace=openshift-network-operator
  22. ```
  23.  
  24. Make sure these lines exist...
  25.  
  26. ```
  27. image: dougbtv/cluster-network-operator
  28. imagePullPolicy: Always
  29. ```
  30.  
  31. SSH to the node and download our image...
  32.  
  33. ```
  34. [core@ip-10-0-7-170 ~]$ ssh -i .ssh/idkey core@10.0.132.215
  35. [core@ip-10-0-132-215 ~]$ sudo podman pull dougbtv/cluster-network-operator
  36. ```
  37.  
  38. Scale down the deployment, scale it up, watch it.
  39. ```
  40. oc scale deployment network-operator --replicas=0 --namespace=openshift-network-operator
  41. oc scale deployment network-operator --replicas=1 --namespace=openshift-network-operator
  42. watch -n1 oc get pods -o wide --namespace=openshift-network-operator
  43. ```
  44.  
  45. Validate the proper image has been used:
  46.  
  47. ```
  48. [core@ip-10-0-7-170 ~]$ oc describe pod network-operator-55c75cc546-lt5hf --namespace=openshift-network-operator | grep -iP "^\s+image"
  49. Image: dougbtv/cluster-network-operator
  50. Image ID: docker.io/dougbtv/cluster-network-operator@sha256:9fa7327b9c5f66e39e13421bf912423d6176c4ea8ee515e763b6eb4f950eb94e
  51. ```
  52.  
  53. ## Test scenario
  54.  
  55. ```
  56. cat <<EOF | oc create -f -
  57. apiVersion: "k8s.cni.cncf.io/v1"
  58. kind: NetworkAttachmentDefinition
  59. metadata:
  60. name: dhcp-conf
  61. spec:
  62. config: '{
  63. "cniVersion": "0.3.0",
  64. "type": "macvlan",
  65. "master": "eth0",
  66. "mode": "bridge",
  67. "ipam": {
  68. "type": "dhcp"
  69. }
  70. }'
  71. EOF
  72. ```
  73.  
  74. and pod...
  75.  
  76. ```
  77. cat <<EOF | oc create -f -
  78. apiVersion: v1
  79. kind: Pod
  80. metadata:
  81. name: dhcppod
  82. annotations:
  83. k8s.v1.cni.cncf.io/networks: dhcp-conf
  84. spec:
  85. containers:
  86. - name: dhcppod
  87. command: ["/bin/bash", "-c", "sleep 2000000000000"]
  88. image: dougbtv/centos-network
  89. EOF
  90. ```
  91.  
  92. ## hack dhcp server
  93.  
  94. Make sure the subnet `10.0.0.0` actually includes the assigned IP address for eth0.
  95.  
  96. ```
  97. ---
  98. # NOTE: THIS SECTION IS JUST A TEST.
  99. apiVersion: v1
  100. kind: ConfigMap
  101. metadata:
  102. creationTimestamp: null
  103. name: dhcpd-config
  104. namespace: openshift-multus
  105. data:
  106. dhcpd.conf: |
  107. subnet 10.0.0.0 netmask 255.255.0.0 {
  108. authoritative;
  109. range 10.0.0.1 10.0.0.254;
  110. default-lease-time 3600;
  111. max-lease-time 3600;
  112. option subnet-mask 255.255.255.0;
  113. option broadcast-address 10.0.0.255;
  114. # option routers 10.0.0.0;
  115. # option domain-name-servers 8.8.8.8;
  116. # option domain-name "example.com";
  117. }
  118. # subnet 192.168.1.0 netmask 255.255.255.224 {
  119. # range 192.168.1.10 192.168.1.30;
  120. # }
  121. ---
  122. # NOTE: THIS SECTION IS JUST A TEST.
  123. apiVersion: v1
  124. kind: Pod
  125. metadata:
  126. name: dhcpserver
  127. namespace: openshift-multus
  128. spec:
  129. hostNetwork: true
  130. containers:
  131. - name: dhcpserver
  132. image: networkboot/dhcpd
  133. args: ["eth0"]
  134. # args: ["-c","sleep 100000"]
  135. securityContext:
  136. privileged: true
  137. volumeMounts:
  138. - name: dhcpd-config
  139. mountPath: /data/dhcpd.conf
  140. subPath: dhcpd.conf
  141. volumes:
  142. - name: dhcpd-config
  143. configMap:
  144. name: dhcpd-config
  145. items:
  146. - key: dhcpd.conf
  147. path: dhcpd.conf
  148. ```
  149.  
  150. Go ahead and find what box it's running on...
  151.  
  152. ```
  153. [core@ip-10-0-4-180 ~]$ oc project openshift-multus
  154. [core@ip-10-0-4-180 ~]$ oc get pods -o wide | grep -i dhcpserver
  155. dhcpserver 1/1 Running 0 8m43s 10.0.158.153 ip-10-0-158-153.us-west-2.compute.internal <none>
  156. ```
  157.  
  158. Label that node...
  159.  
  160. ```
  161. [core@ip-10-0-4-180 ~]$ oc label node ip-10-0-158-153.us-west-2.compute.internal dhcptest=doug
  162. ```
  163.  
  164. Let's create our DHCP config...
  165.  
  166. ```
  167. cat <<EOF | oc create -f -
  168. apiVersion: "k8s.cni.cncf.io/v1"
  169. kind: NetworkAttachmentDefinition
  170. metadata:
  171. name: dhcp-conf
  172. spec:
  173. config: '{
  174. "cniVersion": "0.3.0",
  175. "type": "macvlan",
  176. "master": "eth0",
  177. "mode": "bridge",
  178. "ipam": {
  179. "type": "dhcp"
  180. }
  181. }'
  182. EOF
  183. ```
  184.  
  185. Now create a pod with a nodeSelector that uses that net-attach-def...
  186.  
  187. ```
  188. cat <<EOF | oc create -f -
  189. apiVersion: v1
  190. kind: Pod
  191. metadata:
  192. name: dhcppod
  193. annotations:
  194. k8s.v1.cni.cncf.io/networks: dhcp-conf
  195. spec:
  196. containers:
  197. - name: dhcppod
  198. command: ["/bin/bash", "-c", "sleep 2000000000000"]
  199. image: dougbtv/centos-network
  200. nodeSelector:
  201. dhcptest: "doug"
  202. EOF
  203. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement