See Spool Knitting for another way of making knitted cording.
Knitting I-Cord:
Using short double-pointed (DP) needles, cast on a small number of stitches,
around 3 to 6.
Knit all the stitches. Switch needles in your hands, so the needle with the
stitches is in your left hand again. Slide the stitches to the other end of the needle and pulling the yarn across the back of the stitches knit the row again. Continue this way, sliding and knitting, until the cord is the length
you wish.
Give the cord a tug to make the little carry across the back disappear,
though there shouldn't be much of a carry if you're only knitting on 3 or 4 stitches.
Attaching To The Edge Of A Finished Project As The I-Cord Is Knit :
Knit across the I-cord to the last stitch, then knit the last stitch together with the first stitch of your project (sweater, jacket...). Pull the yarn across the back of the cord and slide the stitches to the other side of the DP needle as described above.