Networking Flashcards
review the configuration of the DNS operator
oc describe dns.operator/default
Expose a service so it is accessible with a given hostname
oc expose service api-frontend –hostname api.apps.acme.com
create a secure edge route with a TLS certificate
oc create route edge
–service api-frontend
–hostname api.apps.acme.com
–key api.key
–cert api.crt
Create the network policy
oc create -n network-policy -f allow-specific.yaml
View the network policies in the network-policy namespace
oc get networkpolicies -n network-policy
apply the name=network-test label to a namespace
oc label namespace network-test name=network-test
label a node with env=dev
oc label node master01 env=dev
change an existing label
oc label node master01 env=prod –overwrite
Remove a label
oc label node master01 env-
see labels assigned to a node
oc get node master02 –show-labels
determine the value of a single label for a node
oc get node -L failure-domain.beta.kubernetes.io/region
Get list of machines
oc get machines -n openshift-machine-api -o wide
Get list of machine sets
oc get machineset -n openshift-machine-api
edit a machine set
oc edit machineset ocp-qz7hf-worker-us-west-1b -n openshift-machine-api
configure app so that its pods only run on nodes with label env=qa
oc patch deployment/myapp –patch \
> ‘{“spec”:{“template”:{“spec”:{“nodeSelector”:{“env”:”dev”}}}}}’
creates a new project named demo, where all pods will be deployed to nodes that have the label of tier=1
oc adm new-project demo –node-selector “tier=1”
configure a default node selector for an existing project
oc annotate namespace demo \
> openshift.io/node-selector=”tier=2” –overwrite
scaled number of pods in a deployment to three
oc scale –replicas 3 deployment/myapp
Import content of file into mysql
mysql -u root items < /tmp/db-data.sql
How do you print a service IP and nothing else
oc get service/mysql -o jsonpath=”{.spec.clusterIP}”
Connect to mysql using curl
curl -v telnet://172.30.103.29:3306
How do you retrieve the internal IP of a POD
oc get pods -o wide
Troubleshooting steps frontend-mysql
1) Get mysql external and internal IP addresses
2) Start debug frontend pod
3) From debug frontend pod check if mysql is reachable
4) Get frontend IP address
5) Start debug mysql pod
6) From debug mysql pod, check if frontend is reachable
7) Review frontend service: check selector, check endpoint
Network policy to deny all pods network in the namespace
Network policy to allow traffic to hello pod in the network-policy namespace from sample-app pod in network-test namespace over TCP on port 8080.
Network policy to allow trafic from default ingress controller
Second step to allow traffic from default ingress control
put label on default namespace that contains default ingress controller:
oc label namespace default network.openshift.io/policy-group=ingress
Remove the label env from all nodes
oc label node -l env env-
Create secure route
oc create route edge todo-https
–service todo-http
–hostname todo-https.apps.ocp4.example.com
Get svc IP
oc get svc -o wide
Create a debug pod for the todo-http deployment using specific image
oc debug deployment/todo-http –image registry.access.redhat.com/ubi8/ubi:8.4