DO280
Fri Dec 27 10:28:55 UTC 2019
1. Installation - Ansible inventory file & vars
[workstations]
[nfs]
[masters]
[etcd]
[nodes]
openshift_node_labels # e.g. "{'region':'infra', 'node-role.kubernetes.io/compute':'true'}"
[OSEv3:children]
[nodes:vars]
# pre-installation vars
registry_local # registry.lab.example.com
use_overlay_driver # true
insecure_registry # false
run_docker_offline # true
docker_storage_device # /dev/vdb
[OSEv3:vars]
# general vars
openshift_deployment_type # openshift-enterprise
openshift_release # v3.9
openshift_image_tag # v3.9.14
openshift_disable_check # disk_availability,docker_storage,memory_availability
# networking
os_firewall_use_firewalld # true
openshift_master_api_port # 443
openshift_master_console_port # 443
openshift_master_default_subdomain # apps.lab.example.com
# authentication
openshift_master_identity_providers # [{'name':'htpasswd_auth', 'login':'true', 'challenge':'true',
'kind':'HTPasswdPasswordIdentityProvider','filename':'/etc/origin/master/htpasswd'}]
openshift_master_htpasswd_users # {'user':'<<HASH>>'}
# openssl passwd -apr1 <PASSWORD> or htpasswd -nbm <USER> <PASSWORD>
# nfs
openshift_enable_unsupported_configurations # true
openshift_hosted_registry_storage_kind # nfs
openshift_hosted_registry_storage_access_modes # ReadWriteMany
openshift_hosted_registry_storage_nfs_directory # /exports
openshift_hosted_registry_storage_nfs_options # "*(rw,root_squash)"
openshift_hosted_registry_storage_volume_name # registry
openshift_hosted_registry_storage_volume_size # 40Gi
# etcd
openshift_hosted_etcd_storage_kind # nfs
openshift_hosted_etcd_storage_access_modes # ["ReadWriteOnce"]
openshift_hosted_etcd_storage_nfs_directory # /exports
openshift_hosted_etcd_storage_nfs_options # "*(rw,root_squash,sync,no_wdelay)"
openshift_hosted_etcd_storage_volume_name # etcd-vol2
openshift_hosted_etcd_storage_volume_size # 1G
openshift_hosted_etcd_storage_labels # {'storage':'etcd'}
# disconnected installation
oreg_url # registry.lab.example.com/openshift3/ose-${component}:${version}
openshift_examples_modify_imagestreams # true
openshift_docker_additional_registries # registry.lab.example.com
openshift_docker_blocked_registries # registry.lab.example.com,docker.io
# image prefixes
openshift_web_console_prefix # registry.lab.example.com/openshift3/ose-
openshift_cockpit_deployer_prefix # 'registry.lab.example.com/openshift3'
openshift_service_catalog_image_prefix # registry.lab.example.com/openshift3/ose-
openshift_service_broker_prefix # registry.lab.example.com/openshift3/ose-
openshift_service_broker_image_prefix # registry.lab.example.com/openshift3/ose-
openshift_service_broker_etcd_image_prefix # registry.lab.example.com/rhel7
# metrics
openshift_metrics_install_metrics # true2. Installation process
3. Post-installation process
4. Creating a route
a/ Generate private key
openssl genrsa -out <hello.apps.lab.example.com.key> 2048
b/ Generate CSR (request)
c/ Generate certificate
d/ Create secure edge-terminated route
5. ImageStreams
6. Common problems
7. Secrets
8. User accounts, access
ssh root@master htpasswd /etc/origin/master/htpasswd <USER>
a/ Remove capability to create projects for all regular users
b/ Associate user with secure project
c/ Pass environment variable to the new app
oc new-app --name=phpmyadmin --docker-image=registry.lab.example.com/phpmyadmin:4.7 -e PMA_HOST=mysql.secure-review.svc.cluster.local
d/ Failed deployment because of the default security
Enable container to run with root privileges:
e/ Use & update deployment with the new service account
oc edit dc/phpmyadmin # or this command: oc patch dc/phpmyadmin --patch '{"spec":{"template":{"spec":{"serviceAccountName":"<phpmyadmin-account>"}}}}'
JSON representation of the above:
9. Persistent volume
cat mysqldb-volume.yml
10. Controlling scheduling & scaling
cat hello.yml
oc apply -f <hello.yml> oc label node node1.lab.example.com region=apps --overwrite
a/ Disable scheduling on node2
oc adm manage-node --schedulable=false <node2.lab.example.com>
b/ Delete/drain all pods on node2
oc adm drain <node2.lab.example.com> --delete-local-data
c/ Load Docker image locally
docker load -i <phpmyadmin-latest.tar>
d/ Tag local image ID
docker tag <123abcdef> <docker-registry-default.apps.lab.example.com/phpmyadmin:4> docker images
e/ Login to OpenShift internal image registry
TOKEN=$(oc whoami -t)
11. Metrics subsystem
a/ Verify images required by metrics
docker-registry-cli <registry.lab.example.com> search <metrics-cassandra> ssl
b/ Check NFS
ssh root@services cat /etc/exports.d/openshift-ansible.exports
c/ Create PV for NFS share
cat metrics-pv.yml
oc get pv
d/ Add to Ansible inventory file
e/ Run Ansible, verify if it's OK
f/ Top command as admin
oc adm top node --heapster-namespace=openshift-infra --heapster-scheme=https
12. Limits
cat limits.yml
oc describe limits
cat quota.yml
13. Readiness/liveness
14. FAQs
a/ Import the template into OpenShift
oc apply -n openshift -f <template.yml>
b/ Import the Docker image to OpenShift
oc import-image <stream> --from=registry.lab.example.com/todoapp/todoui --confirm -n <todoapp>
c/ Turn service into NodePort
oc edit svc <hello>
d/ Access shell inside the pod
oc rsh <hello-1-abcdef>
e/ Export resource to YAML
f/ Configure router to handle wildcard routes
g/ Autocomplete
source /etc/bash_completion.d/oc
h/ Troubleshooting policies
i/ Security Context Constraints (SCCs)
j/ ConfigMap
oc create configmap <special-config> --from-literal=serverAddress=172.20.30.40
k/ RBAC table
Name of the role
Permissions
cluster-admin
superuser
cluster-status
read-only
edit
no admin, no quota, no access mgmt
basic-user
read account
self-provisioner
cluster role to create new project(s)
admin
anything
l/ Autoscale pods
m/ Tag images
n/ Docker import vs Docker load
o/ OpenShift output vs export
p/ A/B routing
q/ Link secret with service account
oc secret link <service-account> <secret-name>
r/ Process template into a list of resources
s/ Examine pod contents
t/ Delete environment variable
oc set env dc/d1 ENV1- ENV2- ENV3-
u/ Using secrets with ENV & Volumes
oc env dc/printenv --from=secret/printsecret
oc env dc/printenv --from=secret/printsecret --prefix=DB_
oc set volume dc/printenv --add --overwrite --name=db-conf-volume --mount-path /debconf/ --secret-name=printenv-secret
v/ Turn off automatic triggers
oc set triggers dc <NAME> --manual
w/ Allow Jenkins to build & deploy the app
Jenkins container has to be deployed first: Service Catalog > CI/CD > Jenkins (persistent)
Because Jenkins is in a different project than the application
x/ Generate values in templates
To make template available accross the cluster, cluster admin must add it to the openshift namespace
List all parameters from mysql template: oc process --parameters=true -n openshift mysql
Last updated
Was this helpful?