Skip to content

Instantly share code, notes, and snippets.

@sjenning
Created August 1, 2018 21:08
Show Gist options
  • Save sjenning/b6f08f922b5ac0b7fcd204a3949f383a to your computer and use it in GitHub Desktop.
Save sjenning/b6f08f922b5ac0b7fcd204a3949f383a to your computer and use it in GitHub Desktop.
= start an openshift test cluster =
= download dep ==
cd $GOPATH/bin
wget https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64
mv dep-linux-amd64 dep
chmod +x dep
= build operator-sdk =
go get github.com/operator-framework/operator-sdk
cd $GOPATH/src/github.com/operator-framework/operator-sdk
make dep
make install
= install operator-lifecycle-manager (OLM) =
go get github.com/operator-framework/operator-lifecycle-manager
cd $GOPATH/src/github.com/operator-framework/operator-lifecycle-manager
ansible-playbook -i ~/sjenning-okd.inventory deploy/aos-olm/playbook/config.yaml
(begin temporary hack)
pushd deploy/aos-olm/playbook/private/roles
rm olm
ln -s ../../../../../deploy/aos-olm/0.5.0 olm
popd
(end temporary hack)
ansible-playbook -i ~/sjenning-okd.inventory deploy/aos-olm/playbook/config.yaml
oc project operator-lifecycle-manager
oc get pods
= getting started =
cd $GOPATH/src/github.com/example-inc/
operator-sdk new memcached-operator --api-version=cache.example.com/v1alpha1 --kind=Memcached
cd memcached-operator
code pkg/apis/cache/v1alpha1/types.go
===
type MemcachedSpec struct {
// Size is the size of the memcached deployment
Size int32 `json:"size"`
}
type MemcachedStatus struct {
// Nodes are the names of the memcached pods
Nodes []string `json:"nodes"`
}
===
operator-sdk generate k8s
https://github.com/operator-framework/getting-started/pull/12
pushd pkg/stub
wget https://raw.githubusercontent.com/rhuss/getting-started/4a2e8f347dc63fdb8e01f7f0c1bf2f7a12927fc7/handler.go.tmpl
mv handler.go.tmpl handler.go
popd
operator-sdk build docker.io/sjenning/memcached-operator:v0.0.1
docker push docker.io/sjenning/memcached-operator:v0.0.1
oc apply -f deploy/crd.yaml
oc new-project memcached
oc apply -f deploy/rbac.yaml
wget http://file.rdu.redhat.com/sjenning/operator-demo/memcachedoperator.0.0.1.yaml
vi memcachedoperator.0.0.1.yaml
oc apply -f memcachedoperator.0.0.1.yaml
oc get deployments
oc get pods
oc get ClusterServiceVersion-v1s
oc get ClusterServiceVersion-v1s memcachedoperator.v0.0.1 -o json | jq '.status'
wget http://file.rdu.redhat.com/sjenning/operator-demo/memcachedoperator.0.0.2.yaml
grep replaces memcachedoperator.0.0.2.yaml
oc apply -f memcachedoperator.0.0.2.yaml
oc get pods
oc get ClusterServiceVersion-v1s
wget http://file.rdu.redhat.com/sjenning/operator-demo/memcached-for-wordpress.yaml
vi memcached-for-wordpress.yaml
oc apply -f memcached-for-wordpress.yaml
oc get Memcached
oc get deployments
oc get pods
vi memcached-for-wordpress.yaml
===
size: 2
===
oc apply -f memcached-for-wordpress.yaml
oc get deployments
oc get pods
cleanup
oc delete project memcached
oc delete project operator-lifecycle-manager
oc delete crd --all
rm -rf $GOPATH/src/github.com/example-inc/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment