Kubernetes vs OpenShift
Kubernetes | OpenShift |
---|---|
Namespace | Project |
Ingress | Route |
Deployment
|
DeploymentConfig
|
Kustomize | Template |
$ kubectl create -f hello.yml
$ kubectl apply -f hello.yml
$ kubectl get ingresses.v1.networking.k8s.io
Kustomize
A kustomization is a directory containing a kustomization.yml file.
https://kubernetes.io/docs/tasks/manage-kubernetes-objects/kustomization/
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- mydeployment.yml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- mydeployment.yaml
images:
- name: image
newName: new-image
newTag: new-tag
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- mydeployment.yaml
secretGenerator:
- name: mycert
namespace: openshift-config
files:
- tls.crt=my-priv-cert.crt
- tls.key=my-priv-cert.key
generatorOptions:
disableNameSuffixHash: true
A kustomization without a bases field is a base.
An overlay includes all resources in its bases.
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
bases:
- path-to-kustomization
Validate your Kustomize configurations.
$ oc kustomize kustomize_folder
$ oc apply --dry-run -k config
Apply your Kustomize configurations.
$ kubectl apply -k directory_name
Image Streams
Image streams use a unique SHA256 identifier instead of a mutable image tag. This is more robust since image tags (:latest or :v1.1) can change without further notice.
Annotating Deployments with Image Stream Triggers
Key: image.openshift.io/triggers
Value:
[
{
"from": {
"kind": "ImageStreamTag",
"name": "example:latest",
"namespace": "myapp"
},
"fieldPath": "spec.template.spec.containers[?(@.name==\"web\")].image",
"paused": false
},
...
]
$ skopeo copy \
docker://quay.io/redhattraining/versioned-hello:v1.0 \
docker://quay.io/your_account/versioned-hello:latest
$ oc get imagestreams
Import image and create image streams and set periodically scheduled (--scheduled) imports to get latest updates.
$ oc import-image quay.io/your_account/versioned-hello:latest --confirm --scheduled
$ oc set triggers deployment/hello --from-image versioned-hello:latest -c hello
No comments:
Post a Comment